def is_login_valid(cls, email: str, password: str) -> bool: user = cls.find_by_email(email) if not Utils.check_hashed_password(password, user.password): raise UserErrors.IncorrectPasswordError('Incorrect Password.') return True
def is_login_valid(cls, email: str, password: str) -> bool: """ Verifies the email and password provided for a :class:`.User`. Parameters ---------- email : str The email to be verified. password : str The password to be verified. Returns ------- bool True if the email and password is valid, False otherwise. Raises ------ UserErrors.IncorrectPasswordError If an incorrect password was provided. """ user = cls.find_by_email(email) if not Utils.check_hashed_password(password, user.password): raise UserErrors.IncorrectPasswordError( 'Your password was incorrect') return True
def is_login_valid(email, password): user_data = Database.find_one(UserConstants.COLLECTION, {"email": email}) if user_data is None: raise UserErrors.UserNotExistsError("Your user does not exist") if not Utils.check_hashed_password(password, user_data['password']): raise UserErrors.IncorrectPasswordError("Your password is wrong") return True
def login_is_valid(username, password): user_data = Database.find_one("users", {"username": username}) if user_data is None: raise UserErrors.UserNotExistError("The username doesn't exist") if not Utils.check_hashed_password(password, user_data['password']): raise UserErrors.IncorrectPasswordError("Incorrect password") return True
def is_login_valid(cls, email: str, password: str) -> bool: user = cls.find_by_email(email) if not Utils.check_hashed_password( password, user.val() ['password']): #XXX: not sure what object user will be raise errors.IncorrectPasswordError( 'The password entered was incorrect.') return True
def is_login_valid(cls, email: str, password: str) -> bool: user = cls.find_by_email( email) # if not found this will produce an error from endpoint if not Utils.check_hashed_password(password, user.password): raise UserErrors.IncorrectPasswordError( 'The password entered is incorrect.') return True
def is_login_valid(cls, email: str, password: str) -> bool: # check if user exists -- if so, continue user = cls.find_by_email(email) # check if the encrypted/ hashed passwords match -- if not, give message that password was incorrect if not Utils.check_hashed_password(password, user.password): raise UserErrors.IncorrectPasswordError('Your password was incorrect.') return True
def is_login_valid(cls, email: str, password: str) -> bool: # Find the user in the database user = cls.find_by_email(email) # Verify password if not Utils.check_hashed_password(password, user.password): raise UserErrors.IncorrectPasswordError( 'Your password was incorrect.') return True
def is_login_valid(cls, email: str, password: str) -> bool: user = cls.find_by_email(email) # Note - do not catch exception when user not found # let error get passed back to the login_user view if not Utils.check_hashed_password(password, user.password): raise UserErrors.IncorrectPasswordError( 'The password entered was incorrect') return True
def is_login_valid(cls, username: str, password: str) -> bool: """ Verify the login is valid. """ user = cls.find_by_username(username=username) if not Utils.check_hashed_password(password, user.password): raise errors.IncorrectPasswordError( 'The password you have entered is incorrect.') return True
def login_admin(): if request.method == 'POST': username = request.form.get('admin_username') password = request.form.get('admin_password') if Utils.check_hashed_password( password, admin.ADMIN_PASSWORD) and username == admin.ADMIN_USERNAME: return 'Welcome to admin page' else: return 'Your credentials were wrong.' else: return "Page upcoming!!!"
def login_valid_user(email, password): """ :param email: user's email :param password: user's password :return: True if valid, False otherwise """ userData = Database.find_one("users", {'email': email}) if userData is None: raise UserNotExistsError("this user does not existed!") return False if not Utils.check_hashed_password(password, userData['password']): raise UserIncorrectPasswordError("Incorrect password!") return False return True
def is_login_valid(cls, email: str, password: str) -> bool: """ This method verifies that an e-mail/password combo (as sent by the site forms) is valid or not. Checks that the e-mail exists, and that the password associated to that e-mail is correct. :param email: The user's email :param password: The password :return: True if valid, an exception otherwise """ user = cls.find_by_email(email) if not Utils.check_hashed_password(password, user.password): raise UserErrors.IncorrectPasswordError("Your password was wrong.") return True
def change_password(): if request.method == 'POST': current_password = request.form['current'] user = User.find_by_email(session['email']) current_password_confirm = user.password new_password = request.form['new-password'] new_password_confirm = request.form['new-password-confirm'] if not Utils.check_hashed_password(current_password, current_password_confirm): flash('Incorrect password.', 'danger') elif new_password != new_password_confirm: flash('The passwords entered do not match.', 'danger') else: user.password = Utils.hash_password(new_password) user.save_to_firebase() return redirect(url_for('users.settings'))
def is_login_valid(email, password): """ This method verifies that an e-mail/password combo (as sent by the site forms) is valid or not. Checks that the e-mail exists, and that the password associated to that e-mail is correct. """ user_data = Database.find_one( "users", {"email": email}) # Password in sha512 -> pbkdf2_sha512 if user_data is None: flash(f'User {email} does not exist. Try again or') redirect(url_for('login')) return False if not Utils.check_hashed_password(password, user_data['password']): flash('Your password was wrong. Try again!') redirect(url_for('login')) return False return True
def is_login_valid(cls, email, password): """ This method verifies that an e-mail/password combo (as sent by the site forms) is valid or not. Checks that the e-mail exists, and that the password associated to that e-mail is correct. :param email: The user's email :param password: A sha512 hashed password :return: True if valid, False otherwise """ user_data = Database.find_one(UserConstants.COLLECTION, {"email": email}) # Password in sha512 -> pbkdf2_sha512 if user_data is None: # Tell the user that their e-mail doesn't exist raise UserErrors.UserNotExistsError("Your user does not exist.") if not Utils.check_hashed_password(password, user_data['password']): # Tell the user that their password is wrong raise UserErrors.IncorrectPasswordError("Your password was wrong.") return cls(**user_data)
def is_login_valid(email, password): """ This method verify that an e-mail/password combo (as sent by the site forms) is valid or not. Checks that e-mail exists, and that the password associated to that e-mail is correct. :param email: The user's e-mail :param password: A sha512 hashed password :return: True if valid, False otherwise """ user_data = Database.find_one(UserConstants.COLLECTION, {"email": email}) if user_data is None: # Tell the user that their e-mail doesn't exist. raise UserErrors.UserNotExistsError("Your user does not exist.") if not Utils.check_hashed_password(password, user_data['password']): # Tell the user that their password is wrong raise UserErrors.IncorrectPasswordError("Your password was wrong.") return True
def is_login_valid(email, password): """ Method Verifies if email and combo is valid if email exist and password associated with that email is correct :param email: The user's email :param password: A sha512 hashed password :return True if valid, False otherwise """ user_data = Database.find_one( "users", {"email": email}) # Password in sha512 -> pbkdf2_sha512 if user_data is None: # Tell user that their email doesnt exist raise UserErrors.UserError("User Doesn't Exist.") if not Utils.check_hashed_password(password, user_data['password']): # Tell user that the password is wrong raise UserErrors.UserError("Password is wrong") return True
def is_login_valid(email, password): """ This method verifies that an email and password combo(as sent by the site forms) is valid or not. Checks that the email exists and the password associated with it is correct. :param email: The user's email :param password: A sha512 hashed password :return: True if valid, False otherwise """ user_data = Database.find_user_email( email) # password in sha512-> pbkdf2_sha512 if user_data is None: # tell the user the email does not exists raise UserErrors.UserNotExistsError("This email does not exists.") if not Utils.check_hashed_password(password, user_data['password']): # tell the user that the password is incorrect raise UserErrors.IncorrectPasswordError("Your password was wrong.") if user_data['email_verified'] != 'yes': raise UserErrors.EmailNotVerfiedError( "Please verify your e-mail before accessing your dashboard.") return True
def is_login_valid(email, password): """ This method verifies that an email/password combo (as sent by the site forms) is valid or not. Chacks that the e-mail exists, and that the password associated to that email is correct. :param email: The user's email :param password: A sha512 hashed password :return: True if valid, Flase otherwise """ user_data = Database.find_one( UserConstants.COLLECTION, {"email": email}) # password in sha512 -> pbkdf2_sha512 if user_data is None: raise UserErrors.UserNotExistsError( "Your user does not exist. If you want to login, then register." ) elif not Utils.check_hashed_password(password, user_data['password']): raise UserErrors.IncorrectPasswordError( "Your password was wrong. Please try again.") return True
def is_login_valid(cls, email, password): user = cls.find_by_email(email) for users in user: if not Utils.check_hashed_password(password, users.password): raise UserErrors.IncorrectPasswordError('The email id or password is incorrect') return True