19 lines
496 B
Python
19 lines
496 B
Python
|
import hashlib
|
||
|
|
||
|
from kfet.models import Account
|
||
|
|
||
|
class KFetBackend(object):
|
||
|
def authenticate(self, request):
|
||
|
password = request.META.get('HTTP_KFETPASSWORD')
|
||
|
if not password:
|
||
|
return None
|
||
|
|
||
|
try:
|
||
|
password_sha1 = hashlib.sha1(password.encode()).hexdigest()
|
||
|
account = Account.objects.get(password=password_sha1)
|
||
|
user = account.cofprofile.user
|
||
|
except Account.DoesNotExist:
|
||
|
return None
|
||
|
|
||
|
return user
|