diff --git a/src/controllers/auth.js b/src/controllers/auth.js index 8cf4b9a840..f4e38af542 100644 --- a/src/controllers/auth.js +++ b/src/controllers/auth.js @@ -206,16 +206,16 @@ api.resetPassword = function(req, res, next){ if (!user) return res.send(500, {err:"Couldn't find a user registered for email " + email}); user.auth.local.salt = salt; user.auth.local.hashed_password = hashed_password; - utils.sendEmail({ - from: "HabitRPG ", - to: email, - subject: "Password Reset for HabitRPG", - text: "Password for " + user.auth.local.username + " has been reset to " + newPassword + ". Log in at " + nconf.get('BASE_URL'), - html: "Password for " + user.auth.local.username + " has been reset to " + newPassword + ". Log in at " + nconf.get('BASE_URL') + utils.txnEmail(user, 'reset-password', { + NEW_PASSWORD: newPassword, + URL: nconf.get('BASE_URL'), + USERNAME: user.auth.local.username + }); + user.save(function(err){ + if(err) return next(err); + res.send('New password sent to '+ email); + email = salt = newPassword = hashed_password = null; }); - user.save(); - res.send('New password sent to '+ email); - email = salt = newPassword = hashed_password = null; }); };