v1.18.x
barisusakli 8 years ago
parent 27b030a71c
commit 37be43a3c5

@ -90,12 +90,14 @@ var emailer = require('../emailer');
}; };
UserEmail.confirm = function (code, callback) { UserEmail.confirm = function (code, callback) {
db.getObject('confirm:' + code, function (err, confirmObj) { async.waterfall([
if (err) { function (next) {
return callback(new Error('[[error:parse-error]]')); db.getObject('confirm:' + code, next);
} },
function (confirmObj, next) {
if (confirmObj && confirmObj.uid && confirmObj.email) { if (!confirmObj || !confirmObj.uid || !confirmObj.email) {
return next(new Error('[[error:invalid-data]]'));
}
async.series([ async.series([
async.apply(user.setUserField, confirmObj.uid, 'email:confirmed', 1), async.apply(user.setUserField, confirmObj.uid, 'email:confirmed', 1),
async.apply(db.delete, 'confirm:' + code), async.apply(db.delete, 'confirm:' + code),
@ -106,12 +108,10 @@ var emailer = require('../emailer');
function (next) { function (next) {
plugins.fireHook('action:user.email.confirmed', { uid: confirmObj.uid, email: confirmObj.email }, next); plugins.fireHook('action:user.email.confirmed', { uid: confirmObj.uid, email: confirmObj.email }, next);
}, },
], function (err) { ], next);
callback(err ? new Error('[[error:email-confirm-failed]]') : null);
});
} else {
callback(new Error('[[error:invalid-data]]'));
} }
], function (err) {
callback(err);
}); });
}; };
}(exports)); }(exports));

Loading…
Cancel
Save