Skip to content

Node.js based forum software built for the modern web

closes #4211

barisusakli6951dc1fe2b6
diff --git a/public/src/client/account/edit/username.js b/public/src/client/account/edit/username.js
index 4fcddf81f5..4448568157 100644
--- a/public/src/client/account/edit/username.js
+++ b/public/src/client/account/edit/username.js
@@ -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);
diff --git a/src/user/profile.js b/src/user/profile.js
index e157a99671..50aa92c1d0 100644
--- a/src/user/profile.js
+++ b/src/user/profile.js
@@ -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);
});
});