用户认证
Authentication of user
我正在尝试在登录时检查我的密码,我还对我的密码进行了哈希处理。所以我正在使用 brcrypt 进行比较。但它给我错误 enter image description here my user schema is this enter image description here and my login functoin is this enter image description here
let user = await User.findOne({ email: req.body.email }).lean().exec();
应该是
let user = await User.findOne({ email: req.body.email });
因为lean
的结果是plain old JavaScript objects (POJOs), not Mongoose documents.
Ref to here
我正在尝试在登录时检查我的密码,我还对我的密码进行了哈希处理。所以我正在使用 brcrypt 进行比较。但它给我错误 enter image description here my user schema is this enter image description here and my login functoin is this enter image description here
let user = await User.findOne({ email: req.body.email }).lean().exec();
应该是
let user = await User.findOne({ email: req.body.email });
因为lean
的结果是plain old JavaScript objects (POJOs), not Mongoose documents.
Ref to here