26 lines
745 B
Python
26 lines
745 B
Python
from geruecht.model.accessToken import AccessToken
|
|
from datetime import datetime
|
|
import hashlib
|
|
|
|
class AccesTokenController():
|
|
tokenList = None
|
|
|
|
def __init__(self):
|
|
self.tokenList = []
|
|
|
|
def findAccesToken(self, token):
|
|
for accToken in self.tokenList:
|
|
if accToken == token:
|
|
return accToken
|
|
return None
|
|
|
|
def createAccesToken(self, user):
|
|
time = datetime.ctime(datetime.now())
|
|
token = hashlib.md5((time + user.password).encode('utf-8')).hexdigest()
|
|
self.tokenList.append(AccessToken(user, token))
|
|
print(self.tokenList)
|
|
return token
|
|
|
|
def isSameGroup(self, accToken, group):
|
|
return True if accToken.user.group == group else False
|