This commit is contained in:
barisusakli
2016-02-23 15:35:16 +02:00
parent 58a849f206
commit 6951dc1fe2
2 changed files with 7 additions and 6 deletions

View File

@@ -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);

View File

@@ -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);
});
});