Enhanced User Management page error message
Description 1:
When WebUI creates the user with an already existing username
the error message will display the exact failure reason.
Tested:
Step 1: Login to webUI and navigate to user management page
Step 2: Create new user with username "testUser1"
Step 3: Create another user with same username "testUser1"
Step 4: WEB UI will through the error message
as "Username 'testuser1' already exists."
Description 2:
User can able to disable and change the root user via WebUI
Now restricted to disable the root user and changing the
root user privilege.
Tested:
Step 1: Login to Web UI with root user
Step 2: Navigate to User management page
Step 3: Try to modify the root user's details
Step 4: WebUI won't allow to disable the user,
username change and privilege change
Step 5: Login Web UI with non-root user
Step 6: Web UI won't allow to modify or delete the root
user's details
Change-Id: I0e38215b51fb058984664ec38ae9613e18043ed7
Signed-off-by: Sivaprabu Ganesan <sivaprabug@ami.com>
diff --git a/src/locales/en-US.json b/src/locales/en-US.json
index ffb6a2e..0796c67 100644
--- a/src/locales/en-US.json
+++ b/src/locales/en-US.json
@@ -581,6 +581,7 @@
"errorBatchDisable": "Error disabling %{count} user. | Error disabling %{count} users.",
"errorBatchEnable": "Error enabling %{count} user. | Error enabling %{count} users.",
"errorCreateUser": "Error creating user '%{username}'.",
+ "errorAlreadyExistUser": "Username '%{username}' already exists.",
"errorDeleteUser": "Error deleting user '%{username}'.",
"errorLoadAccountSettings": "Error loading account settings",
"errorLoadUsers": "Error loading users.",
diff --git a/src/locales/ru-RU.json b/src/locales/ru-RU.json
index 8993b82..477cde7 100644
--- a/src/locales/ru-RU.json
+++ b/src/locales/ru-RU.json
@@ -581,6 +581,7 @@
"errorBatchDisable": "Ошибка отключения %{count} пользователя. | Ошибка отключения %{count} пользователей.",
"errorBatchEnable": "Ошибка включения %{count} пользователя. | Ошибка включения %{count} пользователей.",
"errorCreateUser": "Ошибка создания пользователя '%{username}'.",
+ "errorAlreadyExistUser": "имя пользователя '%{username}' уже существует.",
"errorDeleteUser": "Ошибка удаления пользователя '%{username}'.",
"errorLoadAccountSettings": "Ошибка загрузки настроек учётной записи",
"errorLoadUsers": "Ошибка загрузки учётных записей пользователей.",
diff --git a/src/store/modules/SecurityAndAccess/UserManagementStore.js b/src/store/modules/SecurityAndAccess/UserManagementStore.js
index 362f3f6..78dbd43 100644
--- a/src/store/modules/SecurityAndAccess/UserManagementStore.js
+++ b/src/store/modules/SecurityAndAccess/UserManagementStore.js
@@ -113,10 +113,27 @@
})
)
.catch((error) => {
- console.log(error);
- const message = i18n.t('pageUserManagement.toast.errorCreateUser', {
+ let message = i18n.t('pageUserManagement.toast.errorCreateUser', {
username,
});
+ if (error.response && error.response.data) {
+ if (error.response.data['UserName@Message.ExtendedInfo']) {
+ let obj = error.response.data['UserName@Message.ExtendedInfo'];
+ for (var key in obj) {
+ if (obj[key].Message) {
+ let msg = obj[key].Message;
+ if (msg.indexOf('already exists') != -1) {
+ message = i18n.t(
+ 'pageUserManagement.toast.errorAlreadyExistUser',
+ {
+ username,
+ }
+ );
+ }
+ }
+ }
+ }
+ }
throw new Error(message);
});
},
diff --git a/src/views/SecurityAndAccess/UserManagement/ModalUser.vue b/src/views/SecurityAndAccess/UserManagement/ModalUser.vue
index 0f8757c..5a1dc61 100644
--- a/src/views/SecurityAndAccess/UserManagement/ModalUser.vue
+++ b/src/views/SecurityAndAccess/UserManagement/ModalUser.vue
@@ -56,6 +56,7 @@
name="user-status"
data-test-id="userManagement-radioButton-statusDisabled"
:value="false"
+ :disabled="!newUser && originalUsername === disabled"
@input="$v.form.status.$touch()"
>
{{ $t('global.status.disabled') }}
@@ -81,7 +82,7 @@
aria-describedby="username-help-block"
data-test-id="userManagement-input-username"
:state="getValidationState($v.form.username)"
- :disabled="!newUser && originalUsername === 'root'"
+ :disabled="!newUser && originalUsername === disabled"
@input="$v.form.username.$touch()"
/>
<b-form-invalid-feedback role="alert">
@@ -259,6 +260,7 @@
passwordConfirmation: '',
manualUnlock: false,
},
+ disabled: this.$store.getters['global/username'],
};
},
computed: {
diff --git a/src/views/SecurityAndAccess/UserManagement/UserManagement.vue b/src/views/SecurityAndAccess/UserManagement/UserManagement.vue
index c6c556c..b17be86 100644
--- a/src/views/SecurityAndAccess/UserManagement/UserManagement.vue
+++ b/src/views/SecurityAndAccess/UserManagement/UserManagement.vue
@@ -217,12 +217,17 @@
actions: [
{
value: 'edit',
- enabled: true,
+ enabled: this.editEnable(user),
title: this.$t('pageUserManagement.editUser'),
},
{
value: 'delete',
- enabled: user.UserName === 'root' ? false : true,
+ enabled:
+ user.UserName === this.$store.getters['global/username']
+ ? false
+ : true && user.UserName === 'root'
+ ? false
+ : true,
title: this.$tc('pageUserManagement.deleteUser'),
},
],
@@ -247,6 +252,13 @@
this.$store.dispatch('userManagement/getAccountRoles');
},
methods: {
+ editEnable(user) {
+ if ('root' === this.$store.getters['global/username']) {
+ return true;
+ } else {
+ return user.UserName === 'root' ? false : true;
+ }
+ },
initModalUser(user) {
this.activeUser = user;
this.$bvModal.show('modal-user');