Skip to content
This repository was archived by the owner on Jun 7, 2025. It is now read-only.

Commit 378b030

Browse files
committed
fix: gestisci errori durante l'invio dell'email di registrazione e reset della password
1 parent 57c1f50 commit 378b030

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

app/routes/user.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,11 @@ async def register_user(
8787
body=f"Benvenuto in Suppl-AI!\nEcco la tua password temporanea\n\n{password}\n\n Accedi e cambiala subito!",
8888
)
8989
except Exception as e:
90-
# raise HTTPException(
91-
# status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
92-
# detail=f"Failed to send email to user: {e}",
93-
# )
94-
print(f" Error: Failed to send to user the password: {e}")
95-
print(f" To: {user_data.email}")
96-
print(f" Subject: [Suppl-AI] Password Reset")
97-
print(f" Body: Ciao {user.get('name')},\n\nEcco la tua nuova password temporanea:\n\n{password}\n\nAccedi e cambiala subito!")
98-
print(" Error: Failed to send email to user")
90+
raise HTTPException(
91+
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
92+
detail=f"Failed to send email to user: {e}",
93+
)
94+
# print(f" Error: Failed to send to user the password: {e}")
9995

10096
return {"message": "User registered successfully", "password": password}
10197

@@ -368,16 +364,13 @@ async def reset_password(
368364
subject="[Suppl-AI] Password Reset",
369365
body=f"Ciao {user.get('name')},\n\nEcco la tua nuova password temporanea:\n\n{password}\n\nAccedi e cambiala subito!",
370366
)
371-
except Exception:
367+
except Exception as e:
372368
# raise HTTPException(
373369
# status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
374370
# detail=f"Failed to send email to user: {e}",
375371
# )
376372
print(" Error: Failed to send to user the password")
377-
print(f" To: {user_data.email}")
378-
print(f" Subject: [Suppl-AI] Password Reset")
379-
print(f" Body: Ciao {user.get('name')},\n\nEcco la tua nuova password temporanea:\n\n{password}\n\nAccedi e cambiala subito!")
380-
print(" Error: Failed to send email to user")
373+
381374
except Exception as e:
382375
raise HTTPException(
383376
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,

0 commit comments

Comments
 (0)