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

AbstractEmailUser does not normalize emails #112

Closed
weslord opened this issue Apr 17, 2020 · 2 comments
Closed

AbstractEmailUser does not normalize emails #112

weslord opened this issue Apr 17, 2020 · 2 comments
Assignees

Comments

@weslord
Copy link
Contributor

weslord commented Apr 17, 2020

I noticed that AbstractEmailUser does not reproduce the .clean() method that Django's AbstractUser provides, which means normalize_email() (lowercasify the domain portion) is not being invoked on save.

https://github.com/django/django/blob/master/django/contrib/auth/models.py#L363-L365:

    def clean(self):
        super().clean()
        self.email = self.__class__.objects.normalize_email(self.email)

I would assume that this is deliberate, but authtools' implementation of UserManager.create_user() does include normalize_email()

https://github.com/fusionbox/django-authtools/blob/master/authtools/models.py#L12-L17

    def create_user(self, email, password=None, **kwargs):
        email = self.normalize_email(email)
        // ...

Which means that users created with manage.py createsuperuserwill have their emails normalized, but users created through the Django Admin will not.

@weslord
Copy link
Contributor Author

weslord commented Apr 17, 2020

I've submitted a pull request with a fix, on the assumption that calling Django's normalize_email() everywhere is the preferred outcome, and does not conflict with approaches discussed in #11

@bgaudino bgaudino self-assigned this Jul 13, 2022
@bgaudino
Copy link
Contributor

Fixed in #110

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants