diff --git a/routes/routes.js b/routes/routes.js index 7b71ded68054d7afd2fd98bc444d54ecaf7b0bdc..af04837dfa1302b395261899e9ae9d66b9e6ea41 100644 --- a/routes/routes.js +++ b/routes/routes.js @@ -350,10 +350,10 @@ module.exports = function (app, config, passport) { //methods.currentDate(); var emailAddress = req.body.inputEmail; - var emailContent = "Hi there,\n\n"+ + /* var emailContent = "Hi there,\n\n"+ "we've received a request to reset your password. However, this email address is not on our database of registered users.\n\n"+ "Thanks,\nM4_LAB Team"; - var emailSubject = "Account Access Attempted"; + var emailSubject = "Account Access Attempted"; */ async.waterfall([ function(done) { @@ -366,8 +366,8 @@ module.exports = function (app, config, passport) { methods.checkUserEmail(emailAddress, function(err, user){ if (user) { console.log("email: user found"); - emailSubject = "M4_LAB Password Reset"; - emailContent = "Hi User,\n\n"+ + var emailSubject = "M4_LAB Password Reset"; + var emailContent = "Hi User,\n\n"+ "we've received a request to reset your password. If you didn't make the request, just ignore this email.\n\n"+ "Otherwise, you can reset your password using this link: http://localhost:9989/reset/" + token + "\n" + "This password reset is only valid for 1 hour.\n\n"+ @@ -381,12 +381,22 @@ module.exports = function (app, config, passport) { methods.updateCredential(credentialData, function(err) { done(err, token, user); }); + + // send email + mailOptions.to = emailAddress; + mailOptions.subject = emailSubject; + mailOptions.text = emailContent; + smtpTransport.sendMail(mailOptions, function(err) { + done(err, 'done'); + }); } else { - done(err, null, null); + //done(err, null, null); + done(err, 'no user found'); } }); - }, + } + /*, function(token, user, done) { mailOptions.to = emailAddress; mailOptions.subject = emailSubject; @@ -394,13 +404,13 @@ module.exports = function (app, config, passport) { smtpTransport.sendMail(mailOptions, function(err) { done(err, 'done'); }); - } + } */ ], function(err) { if (err) { req.flash('error', 'An error occured. Please try again.'); } else { - req.flash('success', 'An e-mail has been sent to ' + emailAddress + ' with further instructions.'); + req.flash('success', 'If your email is registered, an e-mail has been sent to ' + emailAddress + ' with further instructions.'); } res.redirect('/forgotPwd'); });