如何解决在 node.js 中验证 bcrypt
我在登录时遇到密码验证问题。我得到一个“没有比较”的回复。我在哪里收到错误?
另外 user.password 未定义
function post(req,res) {
User.find({ email: req.body.email,password:req.body.password })
.then(user => {
if (user.length < 1) {
res.status(400).json({
message: "Mail dosent exists"
});
} else {
bcrypt.genSalt(SALT_ROUNDS,function (error,salt) {
console.log("salt: " + "" + salt)
bcrypt.hash(req.body.password,salt,(error,hash) => {
bcrypt.compare(user.password,hash)
.then(result => {
res.status(200).send(result)
console.log("logged")
})
.catch(error => res.status(500).send(error));
console.log("no comparison")
console.log("hash:" + "" + hash)
console.log("hasło:" + "" + user.password)
});
});
}
});
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。