Skip to content

Commit

Permalink
Update registration serializers.py
Browse files Browse the repository at this point in the history
Fix email validation on unverified accounts
  • Loading branch information
dontic committed Apr 16, 2024
1 parent b608360 commit cbd843c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions dj_rest_auth/registration/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,16 @@ def validate_email(self, email):
raise serializers.ValidationError(
_('A user is already registered with this e-mail address.'),
)
else:
query = EmailAddress.objects.filter(email__iexact=email)
if query.exists():
email_address = query.first()
if email_address.user.has_usable_password():
raise serializers.ValidationError(
_(
"A user is already registered with this e-mail address but hasn't been verified their email yet."
),
)
return email

def validate_password1(self, password):
Expand Down

0 comments on commit cbd843c

Please sign in to comment.