Skip to content

forms

django_spire.auth.forms

CaseInsensitiveAuthenticationForm

Bases: AuthenticationForm

clean

Source code in django_spire/auth/forms.py
def clean(self):
    username = self.cleaned_data.get('username')

    if username:
        user = User.objects.filter(username__iexact=username.lower()).first()

        if user is None:
            raise self.get_invalid_login_error()

        self.cleaned_data['username'] = user.username

    return super().clean()