From 50b86d9e0f31a58f34eb7d49daf68e0ddb6a7766 Mon Sep 17 00:00:00 2001 From: Andrew Williams Date: Tue, 15 Jun 2010 20:43:32 +0100 Subject: [PATCH] Modified to use the new login API --- auth.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/auth.py b/auth.py index acfaf0b..7fc4657 100644 --- a/auth.py +++ b/auth.py @@ -3,6 +3,7 @@ from string import lower import simplejson as json import urllib import urllib2 +from hashlib import sha1 from django.contrib.auth.models import User, check_password from settings import * @@ -25,7 +26,7 @@ class DredditAuthBackend: opener = urllib2.build_opener(auth_handler) urllib2.install_opener(opener) - params = { 'user': username } + params = { 'user': username, 'pass': sha1(password).hexdigest() } try: raw = urllib2.urlopen('%s?%s' % (api_url, urllib.urlencode(params))) except urllib2.HTTPError: @@ -33,7 +34,7 @@ class DredditAuthBackend: else: obj = json.loads(raw.read()) - if 'password' in obj and check_password(password, obj['password']): + if 'auth' in obj and obj['auth'] == 'ok': email = obj['email'] valid = True