Updated expiration of password token to 1hr, updated flash message when email is sent with password recovery instructions.

This commit is contained in:
Sahat Yalkabov
2014-02-18 01:16:34 -05:00
parent bde061debf
commit 58c3db89ed

View File

@ -128,7 +128,7 @@ exports.postForgot = function(req, res) {
} }
user.resetPasswordToken = token; user.resetPasswordToken = token;
user.resetPasswordExpires = Date.now() + 10000000; user.resetPasswordExpires = Date.now() + 3600000; // 1 hour
// update the user's record with the token // update the user's record with the token
user.save(function(err) { user.save(function(err) {
@ -166,14 +166,13 @@ exports.postForgot = function(req, res) {
'If you did not request this, please ignore this email and your password will remain unchanged.\n' 'If you did not request this, please ignore this email and your password will remain unchanged.\n'
}; };
// send email
smtpTransport.sendMail(mailOptions, function(err) { smtpTransport.sendMail(mailOptions, function(err) {
if (err) { if (err) {
req.flash('errors', { msg: err.message }); req.flash('errors', { msg: err.message });
return res.redirect('/forgot'); return res.redirect('/forgot');
} else { } else {
// Message to user // Message to user
req.flash('info', { msg: 'If you have an account with that email address then we sent you an email with instructions. Check your email!' }); req.flash('info', { msg: 'We have sent an email to ' + user.email + ' for further instructions.' });
return res.redirect('/forgot'); return res.redirect('/forgot');
} }
}); });