Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- error_messages = {
- 'invalid_login': _(
- "Please enter a correct %(username)s and password. Note that both "
- "fields may be case-sensitive."
- ),
- 'inactive': _("This account is inactive."),
- def clean(self):
- username = self.cleaned_data.get('username')
- password = self.cleaned_data.get('password')
- if username is not None and password:
- self.user_cache = authenticate(self.request, username=username, password=password)
- if self.user_cache is None:
- raise self.get_invalid_login_error()
- else:
- self.confirm_login_allowed(self.user_cache)
- return self.cleaned_data
- def get_invalid_login_error(self):
- return forms.ValidationError(
- self.error_messages['invalid_login'],
- code='invalid_login',
- params={'username': self.username_field.verbose_name},
- )
Add Comment
Please, Sign In to add comment