#28645: AuthenticationForm's inactive user error isn't raised when using
ModelBackend
-------------------------------------+-------------------------------------
Reporter: Guilherme Junqueira | Owner:
| shangdahao
Type: Bug | Status: new
Component: contrib.auth | Version: 1.11
Severity: Normal | Resolution:
Keywords: 2.1 | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Christoph Schwarzenberg):
Is there any progress regarding the issue?
An other suggestion:
In ModelBackend authentication maybe add an optional parameter, defaulting
to False to allow inactive users to pass through authenticate() and catch
them later in AuthenticationForm.confirm_login_allowed()
E.g.
{{{#!python
class ModelBackend:
def authenticate(self, request, username=None, password=None,
allow_inactive=False, **kwargs):
if username is None:
username = kwargs.get(UserModel.USERNAME_FIELD)
try:
user = UserModel._default_manager.get_by_natural_key(username)
except UserModel.DoesNotExist:
# Run the default password hasher once to reduce the timing
# difference between an existing and a nonexistent user
(#20760).
UserModel().set_password(password)
else:
if user.check_password(password) and
(self.user_can_authenticate(user) or allow_inactive):
return user
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/28645#comment:16>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/068.9a81d45561810928465c1c16c042f78e%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.