Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(socialaccounts): Check in User.email for account matching email address #3467

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions allauth/socialaccount/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,14 @@ def _lookup_by_email(self):
self.connect(context.request, address.user)
else:
self.user = address.user
return

user = get_user_model().objects.filter(email__in=emails).first()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not all user models have an email field. Also, email casing needs to be taken into account, so this should likely be replaced by filter_users_by_email(). I think that the existing EmailAddress.objects.lookup(emails).order_by("-verified", "user_id").first() line could be replaced by it, so no need to duplicate the if that follows here.

if user:
if app_settings.EMAIL_AUTHENTICATION_AUTO_CONNECT:
self.connect(context.request, user)
else:
self.user = user

def get_redirect_url(self, request):
url = self.state.get("next")
Expand Down