def login(login): #if login: print('login in APP:', login) g.data = UsersDB(get_db()) user_id = g.data.getUserId(login) if user_id: user_id = user_id[0] else: return False user_hpsw = g.data.getUserPsw(user_id) if user_hpsw: user_hpsw = user_hpsw[0] else: return False code = g.data.addAuthUser(user_id) #print('code', code) if user_id and user_hpsw and code: return user_id, user_hpsw, code return False
def auth(user_id, code): g.data = UsersDB(get_db()) if g.data.isAuthValid(user_id, code): return True return False
def registration(name, hash, login, email): g.data = UsersDB(get_db()) if g.data.addUser(name, hash, login, email): return True return False
def getUserCode(user_id): g.data = UsersDB(get_db()) code = g.data.getUserCode(user_id) if code: return code return False
def getUserIdbyLogin(login): g.data = UsersDB(get_db()) user_id = g.data.getUserIdbyLogin(login) if user_id: return user_id return False
def check_auth_user(user_login): g.data = UsersDB(get_db()) if g.data.checkAuthUser(user_login): return True return False
def getUsers(): g.data = UsersDB(get_db()) users = g.data.getUsers() if users: return users return False
def deleteUser(user_id): g.data = UsersDB(get_db()) delete = g.data.deleteUser(user_id) if delete: return delete else: return False