diff --git a/src/js/client.js b/src/js/client.js index e9f1e6e34..b9f8be77a 100644 --- a/src/js/client.js +++ b/src/js/client.js @@ -1819,6 +1819,7 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout active: user.active, role: user.role }; + if (user.username) data.username = user.username; post('/api/v1/users/' + user.id, data, null, function (error, data, status) { if (error) return callback(error); diff --git a/src/views/users.html b/src/views/users.html index bd6b50ae8..0a48ad1ec 100644 --- a/src/views/users.html +++ b/src/views/users.html @@ -175,6 +175,14 @@

{{ useredit.error.generic }}

+ +
+ +
+ {{ useredit.error.username }} +
+ +
diff --git a/src/views/users.js b/src/views/users.js index 5b7f345fd..4c3100f0c 100644 --- a/src/views/users.js +++ b/src/views/users.js @@ -228,6 +228,7 @@ angular.module('Application').controller('UsersController', ['$scope', '$locatio userInfo: {}, // form fields + username: '', email: '', fallbackEmail: '', aliases: {}, @@ -239,6 +240,7 @@ angular.module('Application').controller('UsersController', ['$scope', '$locatio show: function (userInfo) { $scope.useredit.error = {}; + $scope.useredit.username = userInfo.username; $scope.useredit.email = userInfo.email; $scope.useredit.displayName = userInfo.displayName; $scope.useredit.fallbackEmail = userInfo.fallbackEmail; @@ -271,6 +273,8 @@ angular.module('Application').controller('UsersController', ['$scope', '$locatio // only change those if it is a local user if (!$scope.useredit.source) { + // username is settable only if it was empty previously. it's editable for the "lock" profiles feature + if (!$scope.useredit.userInfo.username) data.username = $scope.useredit.username; data.email = $scope.useredit.email; data.displayName = $scope.useredit.displayName; data.fallbackEmail = $scope.useredit.fallbackEmail; @@ -281,7 +285,11 @@ angular.module('Application').controller('UsersController', ['$scope', '$locatio $scope.useredit.busy = false; if (error.statusCode === 409) { - $scope.useredit.error.email = 'Email already taken'; + if (error.message.toLowerCase().indexOf('email') !== -1) { + $scope.useredit.error.email = 'Email already taken'; + } else if (error.message.toLowerCase().indexOf('username') !== -1) { + $scope.useredit.error.username = 'Username already taken'; + } $scope.useredit_form.email.$setPristine(); $('#inputUserEditEmail').focus(); } else {