Open aayushkuntal opened 1 year ago
The password is not getting hased before the update in the updateUserProfile function of userController.js. It causes the user to update the password but cant login again.
const user = await User.findById(req.user._id); if(user){ user.name=req.body.name||user.name; user.email=req.body.email||user.email; if(req.body.password){ const hashedPassword=await bcrypt.hash(req.body.password,10); user.password=hashedPassword; } const updatedUser=await user.save(); res.json({ _id: updatedUser._id, name: updatedUser.name, email: updatedUser.email, isAdmin: updatedUser.isAdmin, pic: updatedUser.pic, token: generateToken(updatedUser._id) }) }else{ res.status(404); throw new Error('User not found'); } });
Could you please assign this issue to me?
The password is not getting hased before the update in the updateUserProfile function of userController.js. It causes the user to update the password but cant login again.