问题描述
我在登录时遇到密码验证问题。我得到一个“没有比较”的回复。我在哪里收到错误?
另外 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 (将#修改为@)