def authenticate(nick, password): if not (is_valid_login_input(nick, password)): return False connector = DbConnector() data = connector.get_one_result_for_query(QueryGenerator.get_user_data(), (nick, )) connector.close() if data is None: return False else: if pbkdf2_sha256.verify( password, data[2]): # Compares to the hash stored in the users table. return True return False
def is_valid_sign_up_input(nick, email, password): global err if not nick.isalnum(): err = "Nickname can contain only numbers and letters" return False if not password.isalnum(): err = "Password can contain only numbers and letters" return False connector = DbConnector() data = connector.get_one_result_for_query(QueryGenerator.get_user_data(), (nick, )) if data is not None: err = "This nickname is already taken. Please choose a different one" return False data = connector.get_one_result_for_query(QueryGenerator.get_email(), (email, )) if data is not None: err = "This email is already in use" return False connector.close() return True