def login_valid(email, password): user = User.get_by_email(email=email.lower()) if user is None: raise user_exceptions.UserNotExistsException("The user not exists in the system.") if not Utils.check_hashed_password(password=password, hashed_password=user.password): raise user_exceptions.WrongPasswordException("The password is not correct.") 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 was wrong.") return True
def is_login_valid(email, password): user_data = Database.find_one("users", {'email': email}) if user_data is None: raise UserErrors.UserNotExistError("Your User Does not exist!") if not Utils.check_hashed_password(password, user_data['password']): raise UserErrors.IncorrectPasswordError("Your Password was Wrong!") return True
def is_valid_login(username, password): user_data = Database.find_one(UserConstant.COLLECTION, {'username':username}) if user_data is None: raise UserError.UserNotExist("User is not existing in the database") if not Utils.check_hashed_password(password, user_data['password']): raise UserError.PasswordIncorrect("Password is not correct") return True
def change_password(self): old_password = self.old_password_line_edit.text() new_password = self.new_password_line_edit.text() confirm_password = self.confirm_password_line_edit.text() if new_password != confirm_password: msg_box = QtWidgets.QMessageBox(parent=self.teacher_MainWindow) msg_box.setWindowTitle('Error') msg_box.setText('These two new passwords you input are not same!') msg_box.exec_() else: Database.initialize() account = Account.read_account(self.teacher_id) if Utils.check_hashed_password(self.old_password_line_edit.text(), self.teacher_id, account.password): try: Account.modify_account(self.teacher_id, self.new_password_line_edit.text(), 1, self.school) except pymysql.Error as error: msg_box = QtWidgets.QMessageBox(parent=self.teacher_MainWindow) msg_box.setWindowTitle('Error') msg_box.setText(f'read courses failed!\nError: {error}') msg_box.exec_() else: msg_box = QtWidgets.QMessageBox(parent=self.teacher_MainWindow) msg_box.setWindowTitle('Success') msg_box.setText('Modified password successfully!') msg_box.exec_() else: msg_box = QtWidgets.QMessageBox(parent=self.teacher_MainWindow) msg_box.setWindowTitle('Error') msg_box.setText(f'The old password you input is wrong!') msg_box.exec_() Database.close()
def is_login_valid(email, password): user_data = Database.find_one('users', {'email': email}) if user_data is None: raise UserNotExistError("No user with this email is found.") if not Utils.check_hashed_password(password, user_data['password']): raise IncorrectPasswordError("The password you entered is incorrect.") return True
def is_login_valid(email, password): user_data = Database.find_one("users", {"email": email}) if user_data is None: raise UserErrors.UserNotExistsError("User does not exist.") if not Utils.check_hashed_password(password, user_data['password']): raise UserErrors.IncorrectPasswordError( "The password is incorrect.") 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.password): raise UserErrors.IncorrectPasswordError( 'Your password was incorrect') return True
def login_valid(email, password): user = User.get_by_email(email) if user is not None: if not Utils.check_hashed_password(password, user.password): raise UserErrors.IncorrectPasswordError( 'Your password was incorrect') return True return False
def is_login_valid(email, password): user_data = Database.find_one(collection=UserConstants.COLLECTION, query={'email': email}) if user_data is None: raise UserErrors.UserNotExistsError("Your user name does not exists.") if not Utils.check_hashed_password(password, user_data['password']): raise UserErrors.IncorrectPasswordError("Incorrect password") else: return True
def is_login_valid(email, password): user = db.find_one(UserConstraints.Collection, {'email': email}) if user is None: raise exc.UserNotExistsError("Your user does not exist") if not Utils.check_hashed_password(password, user['password']): raise exc.IncorrectPasswordError("Your password is wrong") return True
def is_login_valid(username, password): user_data = Database.find_one(UserConstant.COLLECTION, {'username': username}) if user_data is None: raise UserError.UserNotExistError("User is not exist") if not Utils.check_hashed_password(password, user_data['password']): raise UserError.IncorrectPasswordError("Password is not correct") return True
def is_login_valid(email, sha512_password): user_data = Database.find_one(collection='users', query={'email': email}) if user_data is None: raise UserErrors.UserNotExistError("User doesn't exist.") if not Utils.check_hashed_password(sha512_password, user_data['hashed_password']): raise UserErrors.UserIncorrectPasswordError("Incorrect password.") return True
def is_login_valid(username, password): user_data = Database.find_one(UserConstants.COLLECTION, {"username": username}) if user_data is None: raise UserErrors.UserNotExistsError("User not found.") if not Utils.check_hashed_password(password, user_data['password']): raise UserErrors.IncorrectPasswordError("Incorrect Password") return True
def is_login_valid(email, password): user_data = Database.find_one("users", {"email": email}) # Password is in sha512 -> pbdkf2_sha512 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 was wrong.") return True
def is_login_valid(email, password): user_data = Database.find_one( 'users', {'email': email}) #password in sha512 -> pbkdf2 if user_data is None: raise UserErrors.UserNotExistsError('Your user does not exists.') if Utils.check_hashed_password(password, user_data['password']): raise UserErrors.IncorrectPasswordError("Your password is wrong.") return True
def login_valid(email, password): user_data = User.get_by_email(email) if user_data is None: # Tell the user their email does not exist raise UserErrors.UserNotExistsError("This account does not exist!") if not Utils.check_hashed_password(password, user_data['password']): # Tell the user their password is wrong raise UserErrors.IncorrectPasswordError("Your password was wrong!") return True
def is_login_valid(email,password): user_data=Database.find_one('users',{'email':email}) if user_data is None: raise UserErrors.UserNotExistsError(" User does not exist!") elif not Utils.check_hashed_password(password,user_data['password']): raise UserErrors.IncorrectPasswordError("Incorrect Password") else: return True
def is_login_valid(email, password): query = "SELECT * FROM appusers WHERE email = \'{}\'".format(email) user_data = Database.find_one(query) # 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 True
def is_login_valid(email, password): user_data = Database.find_one("users", {"email": email}) if user_data is None: # email tidak ada pada sistem raise UserErrors.UserNotExistsError( "Tidak ada user yang sama dengan email") if not Utils.check_hashed_password(password, user_data['password']): # password salah raise UserErrors.IncorrectPasswordError("Incorrect Password") return True
def login_user(email, password): # provision for the root_user add encryption for the root user here # else put this in a config file. but figure out a way of upgrade without a complete docker exchange if email == 'alloons_root' and password == 'hbF_ig034': return True else: user_data = Database.find_one(UserConstants.COLLECTION, {'email': email}) if user_data is None: raise UserErrors.UserNotExistsError("This Username Does not exist") if not Utils.check_hashed_password(password, user_data['password']): raise UserErrors.IncorrectPasswordError("Password Incorrect") return True
def is_login_valid(email, password): user_data = Database.find_one( "users", {"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( "In order to log in,you need to register first.") 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.Please try again.") return True
def is_login_valid(email, password): ##this method verifies an email password combo ## email : user email ## password : hashed password ## param : user_data = Database.find_one("users", {"email": email}) if user_data is None: raise UserErrors.UserError('Your user does not exist.') if not Utils.check_hashed_password(password, user_data['password']): raise UserErrors.UserError('Your password was wrong.') return True
def is_login_valid(email, password): user_data = Database.find_one(UserConstant.COLLECTION, {'email':email}) if user_data is None: raise UserError.UserNotExistError("User doesn't exist") if not Utils.check_hashed_password(password, user_data['password']): raise UserError.IncorrectPasswordError("Password is not correct") return True
def is_login_valid(email, password): """ :param email: :param password: :return: """ user_data = Database.find_one("users", {"email": email}) if user_data is None: raise UserErrors.UserNotExistError('Your user does not exist') if not Utils.check_hashed_password(password, user_data['password']): raise UserErrors.IncorrectPasswordError( 'your password is not correct') return True
def login_valid(email, password): """ This method verifies that an email/pw combo is valid :param email: user's email :param password: a sha512 hashed password :return: true if valid else false """ user_data = Database.find_one(UserConstants.COLLECTION, {"email": email}) if user_data is None: raise UserErrors.UserNotExistError("Your user does not exist") if not Utils.check_hashed_password(password, user_data['password']): raise UserErrors.IncorrectPasswordError("Your password was wrong") return True
def is_valid_login(email, password): """ This method verifies that an email/password combo sent by the site forms is valid or not Chekcs that the email exists and the password associated to the email """ user_data = Database.find_one( 'users', {'email': email}) #Password in sha512 -> pbkdf2_sha512 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 was wrong.") return True
def is_login_valid(email, password): ''' This Method verifies that an email/password combo(as sent by the site form) is valid or not, Checks that the e-mail exists, and that the password associated to the email is correct. :param email: The User's email :param password: The sha512 hashed password :return: True if valid, False otherwise ''' user_data = Database.find_one('users', {"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']): #Tells the user that their password is wrong raise UserErrors.IncorrectPasswordError("Your password was wrong")
def is_login_valid(email, password): """ :param email: the user's email :param password: the password(for security) :return: """ #the password in the database is of pbkdf2_sha512 #the password from user is sha512 user_data = Database.find_one(collection=UserConstant.COLLECTION, query={"email": email}) if user_data is None: raise UserErrors.UserNotExistError("User not exist") if not Utils.check_hashed_password(password, user_data['password']): raise UserErrors.IncorrectPasswordError("Password not correct") 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. :param email: The admin's email :param password: A sha512 hashed password :return: True if valid, False otherwise """ pw = os.environ.get('ADMIN_PASSWORD') if email != os.environ.get('ADMIN_EMAIL'): raise AdminErrors.InvalidEmailError('Invalid email') if not Utils.check_hashed_password(password, pw): raise AdminErrors.IncorrectPasswordError('Incorrect password') return True
def is_login_valid(email, password): """ This method verifies that an email/pw combo is valid or not :param email: User email :param password: A sha512 hashed pw :return True/False """ 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 was wrong.") return True
def validate_login(email, password): """ Validates the login with email and password Check if the email's is on the db and if it's associated with that password :param email: The string of user email :param password: sha512 password hash :return: True if it matched or False if else """ user_data = Database.find_one(UserConstants.COLLECTION, query={"email": email}) if user_data is None: raise UserErrors.UserNotFoundException("User not found!") if not Utils.check_hashed_password(password, user_data['password']): raise UserErrors.WrongPassword("Wrong password!") return True
def is_login_valid(email, password): """ This method verifies that an e-mail/password combo (sent by the website form) is valid or not Checks that the email exists & password is correct :param email: User's email :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: raise UserErrors.UserNotExistsError("Your user does not exist.") if not Utils.check_hashed_password(password, user_data['password']): raise UserErrors.IncorrectPasswordError("Your password was wrong.") return True
def is_login_valid(email, password): user_data = Database.find_one(AdminConstants.COLLECTION, {"email": email}) if user_data is None: raise AdminErrors.AdminNotExistError("Your email or password is wrong. <br>" "Contact your admin if you need help" "accessing your account.") pass if not Utils.check_hashed_password(password, user_data['password']): raise AdminErrors.AdminPasswordNotCorrect("Your email or password is wrong. " "Contact your admin if you need help" "accessing your account.") pass return True
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. :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 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): ''' This method verifies that the email-password combo (as sent by the site forms) is valid or not Check that email exists, and that the password associate to 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(UserConstants.COLLECTION, {'email': email}) # password in sha512 -> pbkdf2_sha512 if user_data is None: #tell the user their password doesn't exists raise UserErrors.UserNotExistsError("Your user doesn't exists") # lo levantamos y lo podemos catchear desde donde se lo llame 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 reset_password(username): user = User.find_by_username(username) if request.method == 'POST': origin = request.form['origin'] new = request.form['new'] re_password = request.form['re_password'] if Utils.check_hashed_password(origin, user.password): if new == re_password: user.password = Utils.hash_password(new) user.save_to_mongo() return redirect(url_for('.index')) else: raise UserError.RetypePassword("Your new password and re-type password are not the same") else: raise UserError.PasswordIncorrect("Your origin password is not correct") return render_template('users/reset_password.html')