From d34fe197542264c293642cde1baafe21028b31f0 Mon Sep 17 00:00:00 2001 From: cuom1999 Date: Fri, 25 Aug 2023 16:04:07 -0500 Subject: [PATCH] Check for email exists during verification --- judge/views/email.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/judge/views/email.py b/judge/views/email.py index 922b74f..56c43b9 100644 --- a/judge/views/email.py +++ b/judge/views/email.py @@ -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()