Commit 49e5a58d authored by Rosanny Sihombing's avatar Rosanny Sihombing
Browse files

update forgot password email and user feedback

parent 5523f3fa
...@@ -350,10 +350,10 @@ module.exports = function (app, config, passport) { ...@@ -350,10 +350,10 @@ module.exports = function (app, config, passport) {
//methods.currentDate(); //methods.currentDate();
var emailAddress = req.body.inputEmail; 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"+ "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"; "Thanks,\nM4_LAB Team";
var emailSubject = "Account Access Attempted"; var emailSubject = "Account Access Attempted"; */
async.waterfall([ async.waterfall([
function(done) { function(done) {
...@@ -366,8 +366,8 @@ module.exports = function (app, config, passport) { ...@@ -366,8 +366,8 @@ module.exports = function (app, config, passport) {
methods.checkUserEmail(emailAddress, function(err, user){ methods.checkUserEmail(emailAddress, function(err, user){
if (user) { if (user) {
console.log("email: user found"); console.log("email: user found");
emailSubject = "M4_LAB Password Reset"; var emailSubject = "M4_LAB Password Reset";
emailContent = "Hi User,\n\n"+ 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"+ "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" + "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"+ "This password reset is only valid for 1 hour.\n\n"+
...@@ -381,12 +381,22 @@ module.exports = function (app, config, passport) { ...@@ -381,12 +381,22 @@ module.exports = function (app, config, passport) {
methods.updateCredential(credentialData, function(err) { methods.updateCredential(credentialData, function(err) {
done(err, token, user); done(err, token, user);
}); });
// send email
mailOptions.to = emailAddress;
mailOptions.subject = emailSubject;
mailOptions.text = emailContent;
smtpTransport.sendMail(mailOptions, function(err) {
done(err, 'done');
});
} }
else { else {
done(err, null, null); //done(err, null, null);
done(err, 'no user found');
} }
}); });
}, }
/*,
function(token, user, done) { function(token, user, done) {
mailOptions.to = emailAddress; mailOptions.to = emailAddress;
mailOptions.subject = emailSubject; mailOptions.subject = emailSubject;
...@@ -394,13 +404,13 @@ module.exports = function (app, config, passport) { ...@@ -394,13 +404,13 @@ module.exports = function (app, config, passport) {
smtpTransport.sendMail(mailOptions, function(err) { smtpTransport.sendMail(mailOptions, function(err) {
done(err, 'done'); done(err, 'done');
}); });
} } */
], function(err) { ], function(err) {
if (err) { if (err) {
req.flash('error', 'An error occured. Please try again.'); req.flash('error', 'An error occured. Please try again.');
} }
else { 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'); res.redirect('/forgotPwd');
}); });
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment