Skip to content

Commit 812b89e

Browse files
committed
fix: allow registration with unverified email when verification is not mandatory
Previously, the registration process incorrectly blocked users from registering with an existing but unverified email, even when email verification was not mandatory. This caused a unique constraint error when saving the user. This fix updates the `validate_email` method in `CustomRegisterSerializer` to: - Allow registration if the email exists but is unverified, **only if verification is not mandatory**. - Prevent duplicate registrations if the email is already verified. - Improve error messages for better clarity. This ensures smoother registration flows while maintaining email uniqueness where required.
1 parent 554d7b6 commit 812b89e

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

dj_rest_auth/registration/serializers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,8 @@ def validate_email(self, email):
244244
raise serializers.ValidationError(
245245
"A user is already registered with this email address."
246246
)
247-
else:
247+
elif allauth_account_settings.EMAIL_VERIFICATION == \
248+
allauth_account_settings.EmailVerificationMethod.MANDATORY:
248249
raise serializers.ValidationError(
249250
"This email is already in use but has not been verified."
250251
)

0 commit comments

Comments
 (0)