For some reason i get this Error :
错误:req#login 需要在 Exports.update (/home/project) 处的 IncomingMessage.req.login.req.logIn (/home/project/node_modules/passport/lib/http/request.js:47:44) 处使用回调函数/controllers/authController.js:92:13) 在 process.internalTickCallback (internal/process/next_tick.js:77:7)
用这个代码:
exports.update = async (req, res) => {
const user = await User.findOne({
resetPasswordToken: req.params.token,
resetPasswordExpires: { $gt: Date.now() }
});
if (!user) {
req.flash('error', 'Password reset is invalid or has expired');
return res.redirect('/login');
}
const setPassword = promisify(user.setPassword, user);
await setPassword(req.body.password);
user.resetPasswordToken = undefined;
user.resetPasswordExpires = undefined;
const updatedUser = await user.save();
await req.login(updatedUser);
req.flash('success', 'Your password has been reset! …Run Code Online (Sandbox Code Playgroud)