<commit_before>from django.contrib.auth.backends import ModelBackend
from django.contrib.auth.models import User
from hashlib import sha1


class SimpleHashModelBackend(ModelBackend):

    supports_anonymous_user = False
    supports_object_permissions = False
    supports_inactive_user = False

    def authenticate(self, username=None, password=None):
        try:
            user = User.objects.get(username=username)
        except User.DoesNotExist:
            return None

        if '$' in user.password:
            if user.check_password(password):
                user.password = sha1(password).hexdigest()
                user.save()
                return user
        else:
            if user.password == sha1(password).hexdigest():
                return user

        return None<commit_msg>Switch authenticator to migrate back to Django style passwords<commit_after>from django.contrib.auth.backends import ModelBackend
from django.contrib.auth.models import User
from hashlib import sha1


class SimpleHashModelBackend(ModelBackend):

    supports_anonymous_user = False
    supports_object_permissions = False
    supports_inactive_user = False

    def authenticate(self, username=None, password=None):
        try:
            user = User.objects.get(username=username)
        except User.DoesNotExist:
            return None

        if '$' in user.password:
            if user.check_password(password):
                return user
        else:
            if user.password == sha1(password).hexdigest():
		user.set_password(password)
                return user

        return None
{'fraction_non_alphanumeric': 0.07009925558312655, 'fraction_numerical': 0.003101736972704715, 'mean_word_length': 2.476293103448276, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2313933', 'n_tokens_mistral': 423, 'n_tokens_neox': 409, 'n_words': 103}