|
|
|
@ -165,7 +165,7 @@ module.exports = function(User) {
|
|
|
|
|
return callback();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
db.deleteObjectField('email:uid', userData.email.toLowerCase(), function(err) {
|
|
|
|
|
db.sortedSetRemove('email:uid', userData.email.toLowerCase(), function(err) {
|
|
|
|
|
if (err) {
|
|
|
|
|
return callback(err);
|
|
|
|
|
}
|
|
|
|
@ -176,7 +176,7 @@ module.exports = function(User) {
|
|
|
|
|
User.setUserField(uid, 'gravatarpicture', gravatarpicture, next);
|
|
|
|
|
},
|
|
|
|
|
function(next) {
|
|
|
|
|
db.setObjectField('email:uid', newEmail.toLowerCase(), uid, next);
|
|
|
|
|
db.sortedSetAdd('email:uid', uid, newEmail.toLowerCase(), next);
|
|
|
|
|
},
|
|
|
|
|
function(next) {
|
|
|
|
|
User.setUserField(uid, 'email', newEmail, next);
|
|
|
|
@ -205,61 +205,37 @@ module.exports = function(User) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
User.getUserFields(uid, ['username', 'userslug'], function(err, userData) {
|
|
|
|
|
function update(field, object, value, callback) {
|
|
|
|
|
async.series([
|
|
|
|
|
function(next) {
|
|
|
|
|
db.deleteObjectField(field + ':uid', userData[field], next);
|
|
|
|
|
},
|
|
|
|
|
function(next) {
|
|
|
|
|
User.setUserField(uid, field, value, next);
|
|
|
|
|
},
|
|
|
|
|
function(next) {
|
|
|
|
|
db.setObjectField(object, value, uid, next);
|
|
|
|
|
}
|
|
|
|
|
], callback);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (err) {
|
|
|
|
|
return callback(err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async.parallel([
|
|
|
|
|
function(next) {
|
|
|
|
|
if (newUsername === userData.username) {
|
|
|
|
|
return next();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
update('username', 'username:uid', newUsername, next);
|
|
|
|
|
updateUidMapping('username', uid, newUsername, userData.username, next);
|
|
|
|
|
},
|
|
|
|
|
function(next) {
|
|
|
|
|
var newUserslug = utils.slugify(newUsername);
|
|
|
|
|
if (newUserslug === userData.userslug) {
|
|
|
|
|
return next();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
update('userslug', 'userslug:uid', newUserslug, next);
|
|
|
|
|
updateUidMapping('userslug', uid, newUserslug, userData.userslug, next);
|
|
|
|
|
}
|
|
|
|
|
], callback);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function updateFullname(uid, newFullname, callback) {
|
|
|
|
|
async.waterfall([
|
|
|
|
|
function updateUidMapping(field, uid, value, oldValue, callback) {
|
|
|
|
|
if (value === oldValue) {
|
|
|
|
|
return callback();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async.series([
|
|
|
|
|
function(next) {
|
|
|
|
|
User.getUserField(uid, 'fullname', next);
|
|
|
|
|
},
|
|
|
|
|
function(fullname, next) {
|
|
|
|
|
if (newFullname === fullname) {
|
|
|
|
|
return callback();
|
|
|
|
|
}
|
|
|
|
|
db.deleteObjectField('fullname:uid', fullname, next);
|
|
|
|
|
db.sortedSetRemove(field + ':uid', oldValue, next);
|
|
|
|
|
},
|
|
|
|
|
function(next) {
|
|
|
|
|
User.setUserField(uid, 'fullname', newFullname, next);
|
|
|
|
|
User.setUserField(uid, field, value, next);
|
|
|
|
|
},
|
|
|
|
|
function(next) {
|
|
|
|
|
if (newFullname) {
|
|
|
|
|
db.setObjectField('fullname:uid', newFullname, uid, next);
|
|
|
|
|
if (value) {
|
|
|
|
|
db.sortedSetAdd(field + ':uid', uid, value, next);
|
|
|
|
|
} else {
|
|
|
|
|
next();
|
|
|
|
|
}
|
|
|
|
@ -267,6 +243,17 @@ module.exports = function(User) {
|
|
|
|
|
], callback);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function updateFullname(uid, newFullname, callback) {
|
|
|
|
|
async.waterfall([
|
|
|
|
|
function(next) {
|
|
|
|
|
User.getUserField(uid, 'fullname', next);
|
|
|
|
|
},
|
|
|
|
|
function(fullname, next) {
|
|
|
|
|
updateUidMapping('fullname', uid, newFullname, fullname, next);
|
|
|
|
|
}
|
|
|
|
|
], callback);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
User.changePassword = function(uid, data, callback) {
|
|
|
|
|
if (!uid || !data || !data.uid) {
|
|
|
|
|
return callback(new Error('[[error:invalid-uid]]'));
|
|
|
|
|