forked from DGNum/gestioCOF
fix typo + pep8 + del future imports
This commit is contained in:
parent
6cdb791989
commit
b0e7ebfbc5
1 changed files with 7 additions and 8 deletions
|
@ -1,15 +1,12 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import (absolute_import, division,
|
||||
print_function, unicode_literals)
|
||||
from builtins import *
|
||||
|
||||
import hashlib
|
||||
|
||||
from django.contrib.auth.models import User, Permission
|
||||
from gestioncof.models import CofProfile
|
||||
from kfet.models import Account, GenericTeamToken
|
||||
|
||||
|
||||
class KFetBackend(object):
|
||||
def authenticate(self, request):
|
||||
password = request.POST.get('KFETPASSWORD', '')
|
||||
|
@ -18,13 +15,15 @@ class KFetBackend(object):
|
|||
return None
|
||||
|
||||
try:
|
||||
password_sha256 = hashlib.sha256(password.encode('utf-8')).hexdigest()
|
||||
password_sha256 = (
|
||||
hashlib.sha256(password.encode('utf-8'))
|
||||
.hexdigest()
|
||||
)
|
||||
account = Account.objects.get(password=password_sha256)
|
||||
user = account.cofprofile.user
|
||||
return account.cofprofile.user
|
||||
except Account.DoesNotExist:
|
||||
return None
|
||||
|
||||
return user
|
||||
|
||||
class GenericTeamBackend(object):
|
||||
def authenticate(self, username=None, token=None):
|
||||
|
@ -48,7 +47,7 @@ class GenericTeamBackend(object):
|
|||
try:
|
||||
return (
|
||||
User.objects
|
||||
.select_related('profile__acount_kfet')
|
||||
.select_related('profile__account_kfet')
|
||||
.get(pk=user_id)
|
||||
)
|
||||
except User.DoesNotExist:
|
||||
|
|
Loading…
Reference in a new issue