Answer the question
In order to leave comments, you need to log in
Why bcrypt comparison doesn't work?
Why isMatch returns false, although candidatePassword returns the correct password, and the hash is stored in the database correctly too.
userSchema.methods.comparePassword = function (candidatePassword, cb) {
bcrypt.compare(candidatePassword, this.password, function (err, isMatch) {
if (err) {
console.log('err')
return cb (err)
}
console.log(candidatePassword)
console.log(isMatch)
cb (null, isMatch)
})
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question