Thursday 27 December 2018

How to manually check hashed password stored with Passport.js in MongoDB database

So far I only have this way of verifying if the user entered the password correctly:// Login routes router.route("/login") .get((req, res) => { res.render("login"); }) .post(passport.authenticate("local", { successRedirect: "/", failureRedirect: "/login" })); I want to add a feature where the user can change the password and I have two inputs: old-password and new-password. I need a way to compare the hashed and salted password in the mongodb database and the one that is a string from the old-password input. If the passwords match update the password in the mongodb database with the new-password.Basically I need a function like bool password_verify ( string $password, string $hash) in PHP.I am using passport, passport-local and passport-local-mongoose for my user authentication, everything standard.

Submitted December 27, 2018 at 03:49PM by AmirSaran

No comments:

Post a Comment