

def clean(self):
    '\n        Pass the provided username and password to the active\n        authentication backends and verify the user account is\n        not disabled. If authentication succeeds, the ``User`` object\n        is assigned to the form so it can be accessed in the view.\n        '
    username = self.cleaned_data.get('username')
    password = self.cleaned_data.get('password')
    if (username and password):
        try:
            self.user = authenticate(username=username, password=password)
        except Exception:
            logger.exception(('Error authenticating %s' % username))
            error_msg = _('Internal error while authenticating user')
            raise forms.ValidationError(error_msg)
        if (self.user is None):
            logger.warning(('Failed authentication for %s' % username))
            error_msg = _('The username or password is not correct')
            raise forms.ValidationError(error_msg)
        elif (not self.user.is_active):
            logger.warning(('User account %s is disabled' % username))
            error_msg = _('This user account is disabled')
            raise forms.ValidationError(error_msg)
    return self.cleaned_data

dataset/ETHPy150Open jbittel/django-mama-cas/mama_cas/forms.py LoginForm.clean/original