как насчет использования compareSync
?
Student_Info.findOne({
where: {
email: req.body.email
}
})
.then(student => {
if (!student) throw new Error("No User Found")
// return true if old password equals new password
const validPassword = bcrypt.compareSync(req.body.password, student.password)
if (validPassword) throw new Error("Same Password")
studentData.password = bcrypt.hashSync(req.body.password, 10)
return student.update(studentData)
})
.then(student => {
res.json({
status: student.email + "updated"
});
})
.catch(err => {
res.send("error" + err);
});