added more details to signup error

This commit is contained in:
nvrl committed 2026-02-15 22:29:44 +01:00
1 parent 53c6a64a3c
commit 53f340a8a8
1 file changed
+16 -7
+16 -7
View File
@@ -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)