Home > database >  Authentication of user
Authentication of user

Time:12-21

I am trying to check my password in while logging in in I also have hashed my password. so I am comparing it using brcrypt. But it is giving me error enter image description here my user schema is this enter image description here and my login functoin is this enter image description here

CodePudding user response:

let user = await User.findOne({ email: req.body.email }).lean().exec();

should be

let user = await User.findOne({ email: req.body.email });

Because lean has result is plain old JavaScript objects (POJOs), not Mongoose documents. Ref to here

  • Related