mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-08-05 03:52:14 +00:00
put password resets back to email server, check for non registered users unsubscriptions
This commit is contained in:
parent
e6c1a72c39
commit
16e67ab7d4
2 changed files with 14 additions and 10 deletions
|
|
@ -221,13 +221,10 @@ api.resetPassword = function(req, res, next){
|
|||
if (!user) return res.send(401, {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 <admin@habitrpg.com>",
|
||||
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') + ". After you've logged in, head to "+nconf.get('BASE_URL')+"/#/options/settings/settings and change your password.",
|
||||
html: "Password for <strong>" + user.auth.local.username + "</strong> has been reset to <strong>" + newPassword + "</strong>. Log in at " + nconf.get('BASE_URL') + ". After you've logged in, head to "+nconf.get('BASE_URL')+"/#/options/settings/settings and change your password."
|
||||
});
|
||||
utils.txnEmail(user, 'reset-password', [
|
||||
{name: "NEW_PASSWORD", content: newPassword},
|
||||
{name: "USERNAME", content: user.auth.local.username}
|
||||
]);
|
||||
user.save(function(err){
|
||||
if(err) return next(err);
|
||||
res.send('New password sent to '+ email);
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ var shared = require('../../../common');
|
|||
var User = require('./../models/user').model;
|
||||
var Group = require('./../models/group').model;
|
||||
var Challenge = require('./../models/challenge').model;
|
||||
var EmailUnsubscription = require('./../models/emailUnsubscription').model;
|
||||
var isProd = nconf.get('NODE_ENV') === 'production';
|
||||
var api = module.exports;
|
||||
|
||||
|
|
@ -623,10 +624,16 @@ var inviteByEmails = function(invites, group, req, res, next){
|
|||
}
|
||||
|
||||
// TODO implement "users can only be invited once"
|
||||
invite.canSend = true; // Requested by utils.txnEmail
|
||||
utils.txnEmail(invite, ('invite-friend' + (group.type == 'guild' ? '-guild' : '')), variables);
|
||||
// Check for the email address not to be unsubscribed
|
||||
|
||||
cb();
|
||||
EmailUnsubscription.findOne({email: invite.email}, function(err, unsubscribed){
|
||||
if(err) return cb(err);
|
||||
if(unsubscribed) return cb();
|
||||
|
||||
utils.txnEmail(invite, ('invite-friend' + (group.type == 'guild' ? '-guild' : '')), variables);
|
||||
|
||||
cb();
|
||||
})
|
||||
});
|
||||
}else{
|
||||
cb();
|
||||
|
|
|
|||
Loading…
Reference in a new issue