flaschengeist/geruecht/controller/accesTokenController.py

26 lines
745 B
Python
Raw Normal View History

2019-04-11 21:56:55 +00:00
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