Пример #1
0
 def attempt_login(cls, username, password):
     user = UserService.get_user(username)
     if not user:
         return None
     hashed_pass = hash_password(password, user.salt)
     if hashed_pass != user.password:
         return None
     session = SessionService.get_session_by_user(user)
     if session:
         return session.token
     token = gen_token()
     SessionService.create_session(user, token)
     return token
Пример #2
0
 def attempt_login(cls, username, password):
     user = UserService.get_user(username)
     if not user:
         return None
     hashed_pass = hash_password(password, user.salt)
     if hashed_pass != user.password:
         return None
     session = SessionService.get_session_by_user(user)
     if session:
         return session.token
     token = gen_token()
     SessionService.create_session(user, token)
     return token
Пример #3
0
 def test_returns_token(self):
     token = gen_token()
     assert type(token) is str
     assert len(token) == 64
Пример #4
0
 def test_returns_token(self):
     token = gen_token()
     assert type(token) is str
     assert len(token) == 64