blob: d69d1c7b18b8a311ee5b98a403e04c9be9ceb563 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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, is_active=True)
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
|