summaryrefslogtreecommitdiff
path: root/spoken_auth/backends.py
diff options
context:
space:
mode:
Diffstat (limited to 'spoken_auth/backends.py')
-rw-r--r--spoken_auth/backends.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/spoken_auth/backends.py b/spoken_auth/backends.py
new file mode 100644
index 0000000..a46ea80
--- /dev/null
+++ b/spoken_auth/backends.py
@@ -0,0 +1,25 @@
+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
+from django.contrib.auth.models import update_last_login
+from django.contrib.auth.signals import user_logged_in
+
+User = get_user_model()
+
+class DrupalAuthBackend(object):
+ def authenticate(self, username=None, password=None):
+ user_logged_in.disconnect(update_last_login)
+ try:
+ user = User.objects.get(username=username)
+ if user.check_password(password):
+ return user
+ return None
+ except User.DoesNotExist:
+ return None
+
+ def get_user(self, user_id):
+ try:
+ return User.objects.get(pk=user_id)
+ except User.DoesNotExist:
+ return None