def __init__(self): super().__init__() try: self.session = global_f.connect_db() pass except Exception as error: abort(500, f"Error connect with DB")
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
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