Try to add function to let user reset password. But encounter issue. Before update user table with the new password, I need to check if user enters the right current password. At this step, it always gives me apology message saying 'the current password entered is not right' Here is my code:
# ensure current password is right current_password = db.execute("SELECT hash FROM users WHERE id = :user_id", user_id = session["user_id"]) if pwd_context.encrypt(request.form["oldpassword"]) != current_password["hash"]: return apology("Current password not right")
Is it because I compare the two hash values? Should I dehash the hash value to password to compare?