blob: 2b29615a941f5f984f18342dd41b99c9d37d266f (
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
User = get_user_model()
class DrupalAuthBackend(object):
def authenticate(self, username=None, password=None):
try:
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:
return User.objects.get(pk=user_id)
except User.DoesNotExist:
return None
|