Every time I try to login bcrypt compare returns false but the registration works.
Here is the code for login :
async function init(passport){
const authenticateUser = async (email,password,done) => {
const user = await User.findOne({email : email})
if(user === null) return done(null,false,{message : "Email and Password do not match"});
try{
const isPasswordMatch = await bcrypt.compare(password,user.password);
console.log(isPasswordMatch);
if(isPasswordMatch) return console.log("Up and running");
done(null,false,{message : "Password"});
}
catch(error){done(error)}
}
}
module.exports = init;
Note that I am using passportjs library and excluded the code for it but I had this problem before I added it