mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-05 07:10:30 +01:00
closes #6318
This commit is contained in:
@@ -126,14 +126,24 @@ UserEmail.sendValidationEmail = function (uid, options, callback) {
|
||||
};
|
||||
|
||||
UserEmail.confirm = function (code, callback) {
|
||||
var confirmObj;
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
db.getObject('confirm:' + code, next);
|
||||
},
|
||||
function (confirmObj, next) {
|
||||
function (_confirmObj, next) {
|
||||
confirmObj = _confirmObj;
|
||||
if (!confirmObj || !confirmObj.uid || !confirmObj.email) {
|
||||
return next(new Error('[[error:invalid-data]]'));
|
||||
}
|
||||
|
||||
user.getUserField(confirmObj.uid, 'email', next);
|
||||
},
|
||||
function (currentEmail, next) {
|
||||
if (!currentEmail || currentEmail.toLowerCase() !== confirmObj.email) {
|
||||
return next(new Error('[[error:invalid-email]]'));
|
||||
}
|
||||
|
||||
async.series([
|
||||
async.apply(user.setUserField, confirmObj.uid, 'email:confirmed', 1),
|
||||
async.apply(db.delete, 'confirm:' + code),
|
||||
|
||||
Reference in New Issue
Block a user