allow username to be set by admin, when username is empty

This commit is contained in:
Girish Ramakrishnan
2022-01-12 16:20:50 -08:00
parent 38211e719e
commit 7082dfd418
3 changed files with 18 additions and 1 deletions

View File

@@ -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 {