node.js - 在 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)
});
});
}
});
}
解决方案
推荐阅读
- minio - 在 Minio 减少冗余存储类中将奇偶校验驱动器数设置为 0
- sql - Access SQL 语句:如果没有有效的条目,则返回最后一个
- c# - 如何在谷歌购物中使用 API KEY
- python - 将列表拆分为具有条件的多个列表
- python - 找出 Groupby 操作之间的差异
- javascript - 阻止 javascript 访问小部件的 DOM 元素
- python - Django:我的函数返回一个对象而不是返回值
- sql - 在 Altibase DBMS 中测量执行时间
- amazon-web-services - AWS Lambda ListVersionsByFunction 返回的版本是否已排序?
- r - 按 r 中的列值标记 nmds 图