From 53f340a8a814c92a56b3ee1610fd07cdf85fc6e5 Mon Sep 17 00:00:00 2001 From: Nils Pukropp Date: Sun, 15 Feb 2026 22:29:44 +0100 Subject: [PATCH] added more details to signup error --- backend/api/views.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/backend/api/views.py b/backend/api/views.py index 296455e..1b5de02 100644 --- a/backend/api/views.py +++ b/backend/api/views.py @@ -70,13 +70,22 @@ class UserViewSet(viewsets.ModelViewSet): email_confirmation_code=code ) - send_mail( - 'Verify your Holy Flavors account', - f'Hi {username},\n\nYour verification code is: {code}', - 'noreply@holyflavors.com', - [email], - fail_silently=False, - ) + from smtplib import SMTPException + try: + send_mail( + 'Verify your Holy Flavors account', + f'Hi {username},\n\nYour verification code is: {code}', + 'noreply@holyflavors.com', + [email], + fail_silently=False, + ) + except SMTPException as e: + # If email fails, delete the user so they can try again + user.delete() + return Response( + {'error': f'Failed to send verification email. Please check your SMTP settings. Server said: {e}'}, + status=status.HTTP_500_INTERNAL_SERVER_ERROR + ) return Response({'status': 'User created, please verify your email'}, status=status.HTTP_201_CREATED)