<commit_before>from django.contrib.auth.backends import ModelBackend

from ..users.models import CustomUser as User


class CaseInsensitiveModelBackend(ModelBackend):
    """ Authenticates with a case-insensitive username """

    def authenticate(self, username=None, password=None, **kwargs):
        try:
            user = User.objects.get(username__iexact=username)
            if user.check_password(password):
                return user

        except User.DoesNotExist:
            # Run the default password hasher once to reduce the timing
            # difference between an existing and a non-existing user (#20760).
            User().set_password(password)<commit_msg>Expect a request parameter in CaseInsensitiveModelBackend.authenticate()<commit_after>from django.contrib.auth.backends import ModelBackend

from ..users.models import CustomUser as User


class CaseInsensitiveModelBackend(ModelBackend):
    """ Authenticates with a case-insensitive username """

    def authenticate(self, request, username=None, password=<PASSWORD>, **kwargs):
        try:
            user = User.objects.get(username__iexact=username)
            if user.check_password(password):
                return user

        except User.DoesNotExist:
            # Run the default password hasher once to reduce the timing
            # difference between an existing and a non-existing user (#20760).
            User().set_password(password)
{'fraction_non_alphanumeric': 0.07905686546463246, 'fraction_numerical': 0.006934812760055479, 'mean_word_length': 3.053370786516854, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3485407', 'n_tokens_mistral': 367, 'n_tokens_neox': 353, 'n_words': 107}