In my case we use VK for social registration and some users don't have email in their accounts. And when user with no email try to register he get "User is already registered with this e-mail address." error. It happens because:
utils.email_address_exists
def email_address_exists(email, exclude_user=None):
from .account import app_settings as account_settings
from .account.models import EmailAddress
emailaddresses = EmailAddress.objects
if exclude_user:
emailaddresses = emailaddresses.exclude(user=exclude_user)
ret = emailaddresses.filter(email__iexact=email).exists()
if not ret:
email_field = account_settings.USER_MODEL_EMAIL_FIELD
if email_field:
users = get_user_model().objects
if exclude_user:
users = users.exclude(pk=exclude_user.pk)
ret = users.filter(**{email_field + "__iexact": email}).exists()
return ret
and
serializer.SocialLoginSerializer in it's validate method
if allauth_settings.UNIQUE_EMAIL:
# Do we have an account already with this email address?
account_exists = get_user_model().objects.filter(
email=login.user.email,
).exists()
if account_exists:
raise serializers.ValidationError(
_('User is already registered with this e-mail address.'),
)`
In my case we use VK for social registration and some users don't have email in their accounts. And when user with no email try to register he get "User is already registered with this e-mail address." error. It happens because:
utils.email_address_exists
and
serializer.SocialLoginSerializer in it's validate method
don't filter users by email__isnull=False