diff options
Diffstat (limited to 'drupal_auth/backends.py')
-rw-r--r-- | drupal_auth/backends.py | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/drupal_auth/backends.py b/drupal_auth/backends.py index 1caa1f0..2b29615 100644 --- a/drupal_auth/backends.py +++ b/drupal_auth/backends.py @@ -1,3 +1,5 @@ +import hashlib + from django.contrib.auth.models import User from django.contrib.auth import get_user_model from django.shortcuts import render_to_response, get_object_or_404 @@ -7,17 +9,17 @@ User = get_user_model() class DrupalAuthBackend(object): def authenticate(self, username=None, password=None): try: - user = User(name='cheese') - user.is_active = True - user.is_authenticated = True - return user - except Exception, e: - print e.message - print "blaj"*1000 + user = User.objects.get(username=username) + p = hashlib.md5() + p.update(password) + if user.password == p.hexdigest(): + return user + return None + except User.DoesNotExist: + return None def get_user(self, user_id): try: - print "Hello"*1000 return User.objects.get(pk=user_id) except User.DoesNotExist: return None |