<commit_before>from django.contrib.auth.models import User
from localtv.models import SiteLocation

class OpenIdBackend:

    def authenticate(self, openid_user=None):
        """
        We assume that the openid_user has already been externally validated,
        and simply return the appropriate User,
        """
        return openid_user.user

    def get_user(self, user_id):
        try:
            return User.objects.get(pk=user_id)
        except User.DoesNotExist:
            return None

    def get_perm(self, user_obj, perm):
        if user_obj.is_superuser:
            return True

        from django.contrib.sites.models import Site
        site = Site.objects.get_current()
        sitelocation = SiteLocation.object.get(site=site)
        return sitelocation.user_is_admin(user_obj)
<commit_msg>Make all users get logged in through the OpenIdBackend<commit_after>from django.contrib.auth.models import User
from localtv.models import SiteLocation

class OpenIdBackend:

    def authenticate(self, openid_user=None, username=None, password=<PASSWORD>):
        """
        If we get an openid_userassume that the openid_user has already been
        externally validated, and simply return the appropriate User,

        Otherwise, we check the username and password against the django.auth
        system.
        """
        if openid_user is not None:
            return openid_user.user

        try:
            user = User.objects.get(username=username)
            if user.check_password(password):
                return user
        except User.DoesNotExist:
            return None

    def get_user(self, user_id):
        try:
            return User.objects.get(pk=user_id)
        except User.DoesNotExist:
            return None

    def get_group_permissions(self, user_obj):
        return []

    def get_all_permissions(self, user_obj):
        return []

    def has_perm(self, user_obj, perm_or_app_label):
        """
        We use this method for both has_perm and has_module_perm since our
        authentication is an on-off switch, not permissions-based.
        """
        if user_obj.is_superuser:
            return True

        from django.contrib.sites.models import Site
        site = Site.objects.get_current()
        sitelocation = SiteLocation.objects.get(site=site)
        return sitelocation.user_is_admin(user_obj)

    has_module_perms = has_perm

{'fraction_non_alphanumeric': 0.06702523789822093, 'fraction_numerical': 0.0, 'mean_word_length': 2.4395448079658606, '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': '6929163', 'n_tokens_mistral': 677, 'n_tokens_neox': 659, 'n_words': 186}