def authenticate(username, password): user = models.User.query.filter_by(username=username).first() if user and helpers.verify_password(password, user.password): print(username) g.user = user return user return None
def post(self, username, password): user = User.query.filter(username==username).first_or_404() if verify_password(password, user.password): login_user(LoggedInUser(user)) # Add user to QueueBoards qboards = query_active_queues(user).filter( db.not_(QueueBoard.members.contains([{'user_id': user.id}])) ) current_app.logger.info("Loging In User {}".format(user)) for qboard in qboards: current_app.logger.error("Adding user {} to queue {}".format(user.full_name, qboard.name)) qboard.members.append({'user_id': user.id, 'added_at': dt.now().isoformat()}) db.session.commit() return user abort(401)
def check_username_and_password(email_or_phone_number: str, password: str): email, phone_number = validator.validate_login_request(email_or_phone_number, password) pending_register = register_service.find_one_by_email(email) if email else \ register_service.find_one_by_phone_number(phone_number) if pending_register: raise MustConfirmEmailException() user = repo.find_one_by_email(email) if email else repo.find_one_by_phone_number(phone_number) if not user: raise UserNotFoundException() if not user.is_active: handle_in_active(user) if not verify_password(user.password, password): raise WrongPasswordException() return user
def authenticate(username, password): user = User.query.filter(User.username == username).first() if user and helpers.verify_password(password, user.password): return user return None
def validate_new_hash_password(user_id: int, new_password: str) -> bool: passwords = repo.find_all_password_by_user_id(user_id) for store_password in passwords: print(store_password.password) if verify_password(store_password.password, new_password): return False return True
def change_password(current_password: str, new_password: str, **kwargs) -> User: email = kwargs.get('email') user = repo.find_one_by_email(email) if not user: raise UserNotFoundException() if not verify_password(user.password, current_password): raise WrongCurrentPasswordException() return create_or_update_password(user, new_password)
def authenticate(username, password): user = models.User.objects(username=username).first() if user and helpers.verify_password(password, user.password): return user return None
def test_verify_password(): hash = helpers.encrypt_password("password") assert helpers.verify_password("password", hash) is True assert helpers.verify_password("invalid", hash) is False