def register_user(email, password): user_data = Database.find_one(collection=UserConstants.COLLECTION, query={'email': email}) if user_data is not None: raise UserErrors.UserAlreadyRegisteredError("The e-mail you used to register already exists.") if not Utils.email_is_valid(email): raise UserErrors.InvalidEmailError("The email does not have the correct format.") User(email, Utils.hash_pasword(password)).save_to_db() return True
def register_user(email, password): user_data = Database.find_one(UserConstants.COLLECTION, {"email": email}) if user_data is not None: # Tell User they are already registered raise err.UserAlreadyRegister("The email you used already exists") if not Utils.email_is_valid(email): # Tell user that their email is not constructed properly raise err.InvalidEmailError( "The email does not have the right format") User(email, Utils.hash_pasword(password)).save_to_db() return True
def change_user_password(email, password, new_password, _id): if not User.is_login_valid(email, password): raise UserErrors.IncorrectPasswordError("Incorrect password") User(email, Utils.hash_pasword(new_password), _id).save_to_db() return True