<commit_before>import hashlib
from string import lower
import django.utils.simplejson as json
import urllib
import urllib2
from hashlib import sha1
from django.contrib.auth.models import User, check_password
import settings

class DredditAuthBackend:
    """
    Django authentication backend for authenticating against Dreddit's Auth System.
    """
    def authenticate(self, username=None, password=None):

        valid = False

        if username and password:
            # Call the webservice
            api_url = 'https://auth.dredd.it/api/login/'
            params = { 'user': username, 'pass': <PASSWORD>1(password).hexdigest() }
            try:
                raw = urllib2.urlopen('%s?%s' % (api_url, urllib.urlencode(params)))
            except urllib2.HTTPError:
                pass
            else:
                obj = json.loads(raw.read())

                if 'auth' in obj and obj['auth'] == 'ok':
                    email = obj['email']
                    groups = obj['groups']
                    valid = True

        if valid:
            user, created = User.objects.get_or_create(username=username.lower())
            if created:
                user.set_unusable_password() # disable login through Model backend
                user.save()
            if email:
                user.email = email

            if hasattr(settings, 'DREDDIT_AUTH_CREATE_GROUPS') and settings.DREDDIT_AUTH_CREATE_GROUPS:
                for g in groups:
                    group, created = Group.objects.get_or_create(name=g['name'])
                    user.groups.add(group)

            return user
        return None

    def get_user(self, user_id):<commit_msg>Updated API url<commit_after>import hashlib
from string import lower
import django.utils.simplejson as json
import urllib
import urllib2
from hashlib import sha1
from django.contrib.auth.models import User, check_password
import settings

class DredditAuthBackend:
    """
    Django authentication backend for authenticating against Dreddit's Auth System.
    """
    def authenticate(self, username=None, password=<PASSWORD>):

        valid = False

        if username and password:
            # Call the webservice
            api_url = 'https://auth.pleaseignore.com/api/login/'
            params = { 'user': username, 'pass': <PASSWORD>1(password).hex<PASSWORD>() }
            try:
                raw = urllib2.urlopen('%s?%s' % (api_url, urllib.urlencode(params)))
            except urllib2.HTTPError:
                pass
            else:
                obj = json.loads(raw.read())

                if 'auth' in obj and obj['auth'] == 'ok':
                    email = obj['email']
                    groups = obj['groups']
                    valid = True

        if valid:
            user, created = User.objects.get_or_create(username=username.lower())
            if created:
                user.set_unusable_password() # disable login through Model backend
                user.save()
            if email:
                user.email = email

            if hasattr(settings, 'DREDDIT_AUTH_CREATE_GROUPS') and settings.DREDDIT_AUTH_CREATE_GROUPS:
                for g in groups:
                    group, created = Group.objects.get_or_create(name=g['name'])
                    user.groups.add(group)

            return user
        return None

    def get_user(self, user_id):
{'fraction_non_alphanumeric': 0.09187279151943463, 'fraction_numerical': 0.002944640753828033, 'mean_word_length': 1.891063829787234, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, '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': '6547900', 'n_tokens_mistral': 937, 'n_tokens_neox': 904, 'n_words': 237}