-
Notifications
You must be signed in to change notification settings - Fork 102
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
Add a new authentication backend for case-insensitive emails #31
Conversation
…sible solution for issue #11
# In settings.py | ||
AUTHENTICATION_BACKENDS = ('authtools.backends.CaseInsensitiveEmailBackend',) | ||
""" | ||
def authenticate(self, username=None, password=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have an app that requires me to pass in the request to the authenticate calls.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rockymeza Are you saying this because of the method signature?
If so, django handles the TypeError
https://github.com/django/django/blob/master/django/contrib/auth/__init__.py#L69
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
He wants the lower()
to be called, though, so this should just be changed to be **credentials
instead.
Updated |
We also have a couple of options. This new backend assumes its user has already somehow enforced case-insensitivity of the email address usernames. We either need to add a note to the docstring of the backend, or simply disallow anyone from creating case-sensitive email address usernames (this would be done via |
Not sure I see any reasonable way to enforce this without some grossness. I'd lean towards the backend docstring and something in the docs. |
I added a note of caution for potential users of this new backend. |
…sensitiveEmailModelBackend
A word of caution. Use of this backend presupposes a way to ensure that users cannot | ||
create usernames that differ only in case (e.g., [email protected] and [email protected]). It is | ||
advised that you use this backend in conjunction with the | ||
EmailInsensitiveCreateUserForm provided in the forms module. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is nitpicky, but it would be nice to just provide the qualname for the form:
authtools.forms.EmailInsensitiveCreateUserForm
It's just so that I don't have to parse "the forms module"
This is a possible solution to #11.