Ticket #12103: 12103_with_documentation.diff
File 12103_with_documentation.diff, 1.8 KB (added by , 15 years ago) |
---|
-
django/contrib/auth/forms.py
59 59 username = forms.CharField(label=_("Username"), max_length=30) 60 60 password = forms.CharField(label=_("Password"), widget=forms.PasswordInput) 61 61 62 allow_inactive_logins = False 63 62 64 def __init__(self, request=None, *args, **kwargs): 63 65 """ 64 66 If request is passed in, the form will validate that cookies are … … 78 80 self.user_cache = authenticate(username=username, password=password) 79 81 if self.user_cache is None: 80 82 raise forms.ValidationError(_("Please enter a correct username and password. Note that both fields are case-sensitive.")) 81 elif not self. user_cache.is_active:83 elif not self.allow_inactive_logins and not self.user_cache.is_active: 82 84 raise forms.ValidationError(_("This account is inactive.")) 83 85 84 86 # TODO: determine whether this should move to its own method. -
docs/topics/auth.txt
970 970 971 971 A form for logging a user in. 972 972 973 The ``AuthenticationForm`` rejects users whose ``is_active`` flag is set to ``False``. 974 You may override this behavior and allow inactive users to log in. Do this with a 975 custom form that subclasses ``AuthenticationForm`` like 976 977 .. code-block:: python 978 979 class AuthenticationFormWithInactiveUsersOkay(AuthenticationForm): 980 allow_inactive_logins = True 981 973 982 .. class:: PasswordChangeForm 974 983 975 984 A form for allowing a user to change their password.