mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-07 16:12:53 +01:00
closes #5357
This commit is contained in:
@@ -148,7 +148,7 @@ module.exports = function (SocketUser) {
|
||||
data.email = oldUserData.email;
|
||||
}
|
||||
|
||||
user.updateProfile(data.uid, data, next);
|
||||
user.updateProfile(socket.uid, data, next);
|
||||
},
|
||||
function (userData, next) {
|
||||
function log(type, eventData) {
|
||||
|
||||
@@ -16,6 +16,9 @@ module.exports = function (User) {
|
||||
var fields = ['username', 'email', 'fullname', 'website', 'location',
|
||||
'groupTitle', 'birthday', 'signature', 'aboutme'];
|
||||
|
||||
var updateUid = data.uid;
|
||||
var oldData;
|
||||
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
plugins.fireHook('filter:user.updateProfile', {uid: uid, data: data, fields: fields}, next);
|
||||
@@ -27,14 +30,18 @@ module.exports = function (User) {
|
||||
async.series([
|
||||
async.apply(isAboutMeValid, data),
|
||||
async.apply(isSignatureValid, data),
|
||||
async.apply(isEmailAvailable, data, uid),
|
||||
async.apply(isUsernameAvailable, data, uid),
|
||||
async.apply(isEmailAvailable, data, updateUid),
|
||||
async.apply(isUsernameAvailable, data, updateUid),
|
||||
async.apply(isGroupTitleValid, data)
|
||||
], function (err) {
|
||||
next(err);
|
||||
});
|
||||
},
|
||||
function (next) {
|
||||
User.getUserFields(updateUid, fields, next);
|
||||
},
|
||||
function (_oldData, next) {
|
||||
oldData = _oldData;
|
||||
async.each(fields, function (field, next) {
|
||||
if (!(data[field] !== undefined && typeof data[field] === 'string')) {
|
||||
return next();
|
||||
@@ -43,21 +50,20 @@ module.exports = function (User) {
|
||||
data[field] = data[field].trim();
|
||||
|
||||
if (field === 'email') {
|
||||
return updateEmail(uid, data.email, next);
|
||||
return updateEmail(updateUid, data.email, next);
|
||||
} else if (field === 'username') {
|
||||
return updateUsername(uid, data.username, next);
|
||||
return updateUsername(updateUid, data.username, next);
|
||||
} else if (field === 'fullname') {
|
||||
return updateFullname(uid, data.fullname, next);
|
||||
return updateFullname(updateUid, data.fullname, next);
|
||||
} else if (field === 'signature') {
|
||||
data[field] = S(data[field]).stripTags().s;
|
||||
}
|
||||
|
||||
User.setUserField(uid, field, data[field], next);
|
||||
User.setUserField(updateUid, field, data[field], next);
|
||||
}, next);
|
||||
},
|
||||
function (next) {
|
||||
plugins.fireHook('action:user.updateProfile', {data: data, uid: uid});
|
||||
User.getUserFields(uid, ['email', 'username', 'userslug', 'picture', 'icon:text', 'icon:bgColor'], next);
|
||||
User.getUserFields(updateUid, ['email', 'username', 'userslug', 'picture', 'icon:text', 'icon:bgColor'], next);
|
||||
}
|
||||
], callback);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user