def test_user_password_verification(resource): UserRepo.add_user(username="******", password="******", email="*****@*****.**") assert UserRepo.verify_user("user1", "mypass") == True assert UserRepo.verify_user("user2", "mypass") == False assert UserRepo.verify_user("user1", "not a real password 65") == False
def login(): if current_user and current_user.is_authenticated: return redirect("/home") error = None if request.method == "POST": user = UserRepo.get_user_by_username(request.form["username"]) if UserRepo.verify_user(request.form["username"], request.form["password"]): user = LoggedInUserWrapper(user) login_user(user) return redirect("/home") else: error = "Invalid Credentials. Please try again." return render_template("login.html", error=error)