- def clean(self):
- username = self.cleaned_data.get('username')
- password = self.cleaned_data.get('password')
- user = authenticate(username=username, password=password)
- if user is None:
- raise ValidationError(_('Incorrect username and/or password.'))
- if not user.is_active:
- raise ValidationError(_('This account is disabled.'))
- self._user = user
- self.cleaned_data.get('lt').delete()
- return self.cleaned_data