Check for email exists during verification

This commit is contained in:
cuom1999 2023-08-25 16:04:07 -05:00
parent 20a8f29cd6
commit d34fe19754

View file

@ -80,10 +80,9 @@ def verify_email_view(request, uidb64, token):
except (TypeError, ValueError, OverflowError, User.DoesNotExist):
user = None
if user is not None and default_token_generator.check_token(user, token):
# Update the user's email address
profile = Profile.objects.get(user=user)
new_email = profile.email_change_pending
if new_email:
if new_email and not User.objects.filter(email=new_email).exists():
user.email = new_email
profile.email_change_pending = None
user.save()