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

Conversation

CarlSchwan
Copy link

Submitting Pull Requests

General

  • Make sure you use semantic commit messages.
    Examples: "fix(google): Fixed foobar bug", "feat(accounts): Added foobar feature".
  • All Python code must formatted using Black, and clean from pep8 and isort issues.
  • JavaScript code should adhere to StandardJS.
  • If your changes are significant, please update ChangeLog.rst.
  • If your change is substantial, feel free to add yourself to AUTHORS.

Currently when EMAIL_AUTHENTIFICATION is True, we only checks for other socialaccount accounts and not for accounts in User. The usecase is when migrating the authentification system to one using User.email to store emails to allauth which use EmailAddress.emails

This probably should be behind a configuration flag, I'm not an Django expert so maybe there is better way to do this.

…address

Currently when EMAIL_AUTHENTIFICATION is True, we only checks for other
socialaccount accounts and not for accounts in User. The usecase is when
migrating the authentification system to one using User.email to store
emails to allauth which use EmailAddress.emails

This probably should be behind a configuration flag, I'm not an Django
expert so maybe there is better way to do this.
@coveralls
Copy link

coveralls commented Oct 6, 2023

Coverage Status

coverage: 91.548% (-0.03%) from 91.577% when pulling 342b13e on CarlSchwan:carl/check-emails into 62becf5 on pennersr:main.

@@ -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.

@pennersr
Copy link
Owner

Closed via 26158b2

@pennersr pennersr closed this Oct 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants