Пример #1
0
 def __init__(self):
     super().__init__()
     try:
         self.session = global_f.connect_db()
         pass
     except Exception as error:
         abort(500, f"Error connect with DB")
Пример #2
0
def authenticate(username, password):
    session = global_f.connect_db()
    user = session.execute(select(User).where(User.username == username)).first()[0]
    if user and user.password == hashlib.sha256(password.encode()).hexdigest():
       return user
Пример #3
0
def indentity(payload):
    session = global_f.connect_db()
    user_id = payload['identity']
    user = session.execute(select(User).where(User.id == user_id)).first()[0]
    return user