mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-06 12:31:33 +01:00
closes #4211
This commit is contained in:
@@ -20,7 +20,7 @@ define('forum/account/edit/username', ['forum/account/header'], function(header)
|
||||
}
|
||||
var btn = $(this);
|
||||
btn.addClass('disabled').find('i').removeClass('hide');
|
||||
socket.emit('user.changeUsernameEmail', userData, function(err) {
|
||||
socket.emit('user.changeUsernameEmail', userData, function(err, data) {
|
||||
btn.removeClass('disabled').find('i').addClass('hide');
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
@@ -30,6 +30,7 @@ define('forum/account/edit/username', ['forum/account/header'], function(header)
|
||||
if (userData.username && userslug && parseInt(userData.uid, 10) === parseInt(app.user.uid, 10)) {
|
||||
$('[component="header/profilelink"]').attr('href', config.relative_path + '/user/' + userslug);
|
||||
$('[component="header/username"]').text(userData.username);
|
||||
$('[component="header/usericon"]').css('background-color', data['icon:bgColor']).text(data['icon:text']);
|
||||
}
|
||||
|
||||
ajaxify.go('user/' + userslug);
|
||||
|
||||
@@ -74,10 +74,6 @@ module.exports = function(User) {
|
||||
|
||||
var userslug = utils.slugify(data.username);
|
||||
|
||||
if (userslug === userData.userslug) {
|
||||
return next();
|
||||
}
|
||||
|
||||
if (data.username.length < meta.config.minimumUsernameLength) {
|
||||
return next(new Error('[[error:username-too-short]]'));
|
||||
}
|
||||
@@ -90,6 +86,10 @@ module.exports = function(User) {
|
||||
return next(new Error('[[error:invalid-username]]'));
|
||||
}
|
||||
|
||||
if (userslug === userData.userslug) {
|
||||
return next();
|
||||
}
|
||||
|
||||
User.existsBySlug(userslug, function(err, exists) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
@@ -110,7 +110,7 @@ module.exports = function(User) {
|
||||
return callback(err);
|
||||
}
|
||||
plugins.fireHook('action:user.updateProfile', {data: data, uid: uid});
|
||||
User.getUserFields(uid, ['email', 'username', 'userslug', 'picture'], callback);
|
||||
User.getUserFields(uid, ['email', 'username', 'userslug', 'picture', 'icon:text', 'icon:bgColor'], callback);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user