diff options
Diffstat (limited to 'src/store/modules/AccessControl/LocalUserMangementStore.js')
-rw-r--r-- | src/store/modules/AccessControl/LocalUserMangementStore.js | 64 |
1 files changed, 33 insertions, 31 deletions
diff --git a/src/store/modules/AccessControl/LocalUserMangementStore.js b/src/store/modules/AccessControl/LocalUserMangementStore.js index e9de3cc1..6bc6ec5d 100644 --- a/src/store/modules/AccessControl/LocalUserMangementStore.js +++ b/src/store/modules/AccessControl/LocalUserMangementStore.js @@ -9,7 +9,7 @@ const LocalUserManagementStore = { accountLockoutDuration: null, accountLockoutThreshold: null, accountMinPasswordLength: null, - accountMaxPasswordLength: null + accountMaxPasswordLength: null, }, getters: { allUsers(state) { @@ -21,15 +21,15 @@ const LocalUserManagementStore = { accountSettings(state) { return { lockoutDuration: state.accountLockoutDuration, - lockoutThreshold: state.accountLockoutThreshold + lockoutThreshold: state.accountLockoutThreshold, }; }, accountPasswordRequirements(state) { return { minLength: state.accountMinPasswordLength, - maxLength: state.accountMaxPasswordLength + maxLength: state.accountMaxPasswordLength, }; - } + }, }, mutations: { setUsers(state, allUsers) { @@ -49,19 +49,21 @@ const LocalUserManagementStore = { }, setAccountMaxPasswordLength(state, maxPasswordLength) { state.accountMaxPasswordLength = maxPasswordLength; - } + }, }, actions: { async getUsers({ commit }) { return await api .get('/redfish/v1/AccountService/Accounts') - .then(response => response.data.Members.map(user => user['@odata.id'])) - .then(userIds => api.all(userIds.map(user => api.get(user)))) - .then(users => { - const userData = users.map(user => user.data); + .then((response) => + response.data.Members.map((user) => user['@odata.id']) + ) + .then((userIds) => api.all(userIds.map((user) => api.get(user)))) + .then((users) => { + const userData = users.map((user) => user.data); commit('setUsers', userData); }) - .catch(error => { + .catch((error) => { console.log(error); const message = i18n.t( 'pageLocalUserManagement.toast.errorLoadUsers' @@ -78,7 +80,7 @@ const LocalUserManagementStore = { commit('setAccountMinPasswordLength', data.MinPasswordLength); commit('setAccountMaxPasswordLength', data.MaxPasswordLength); }) - .catch(error => { + .catch((error) => { console.log(error); const message = i18n.t( 'pageLocalUserManagement.toast.errorLoadAccountSettings' @@ -90,29 +92,29 @@ const LocalUserManagementStore = { api .get('/redfish/v1/AccountService/Roles') .then(({ data: { Members = [] } = {} }) => { - const roles = Members.map(role => { + const roles = Members.map((role) => { return role['@odata.id'].split('/').pop(); }); commit('setAccountRoles', roles); }) - .catch(error => console.log(error)); + .catch((error) => console.log(error)); }, async createUser({ dispatch }, { username, password, privilege, status }) { const data = { UserName: username, Password: password, RoleId: privilege, - Enabled: status + Enabled: status, }; return await api .post('/redfish/v1/AccountService/Accounts', data) .then(() => dispatch('getUsers')) .then(() => i18n.t('pageLocalUserManagement.toast.successCreateUser', { - username + username, }) ) - .catch(error => { + .catch((error) => { console.log(error); const message = i18n.t( 'pageLocalUserManagement.toast.errorCreateUser', @@ -136,10 +138,10 @@ const LocalUserManagementStore = { .then(() => dispatch('getUsers')) .then(() => i18n.t('pageLocalUserManagement.toast.successUpdateUser', { - username: originalUsername + username: originalUsername, }) ) - .catch(error => { + .catch((error) => { console.log(error); const message = i18n.t( 'pageLocalUserManagement.toast.errorUpdateUser', @@ -154,10 +156,10 @@ const LocalUserManagementStore = { .then(() => dispatch('getUsers')) .then(() => i18n.t('pageLocalUserManagement.toast.successDeleteUser', { - username + username, }) ) - .catch(error => { + .catch((error) => { console.log(error); const message = i18n.t( 'pageLocalUserManagement.toast.errorDeleteUser', @@ -170,14 +172,14 @@ const LocalUserManagementStore = { const promises = users.map(({ username }) => { return api .delete(`/redfish/v1/AccountService/Accounts/${username}`) - .catch(error => { + .catch((error) => { console.log(error); return error; }); }); return await api .all(promises) - .then(response => { + .then((response) => { dispatch('getUsers'); return response; }) @@ -208,19 +210,19 @@ const LocalUserManagementStore = { }, async enableUsers({ dispatch }, users) { const data = { - Enabled: true + Enabled: true, }; const promises = users.map(({ username }) => { return api .patch(`/redfish/v1/AccountService/Accounts/${username}`, data) - .catch(error => { + .catch((error) => { console.log(error); return error; }); }); return await api .all(promises) - .then(response => { + .then((response) => { dispatch('getUsers'); return response; }) @@ -251,19 +253,19 @@ const LocalUserManagementStore = { }, async disableUsers({ dispatch }, users) { const data = { - Enabled: false + Enabled: false, }; const promises = users.map(({ username }) => { return api .patch(`/redfish/v1/AccountService/Accounts/${username}`, data) - .catch(error => { + .catch((error) => { console.log(error); return error; }); }); return await api .all(promises) - .then(response => { + .then((response) => { dispatch('getUsers'); return response; }) @@ -309,15 +311,15 @@ const LocalUserManagementStore = { //GET new settings to update view .then(() => dispatch('getAccountSettings')) .then(() => i18n.t('pageLocalUserManagement.toast.successSaveSettings')) - .catch(error => { + .catch((error) => { console.log(error); const message = i18n.t( 'pageLocalUserManagement.toast.errorSaveSettings' ); throw new Error(message); }); - } - } + }, + }, }; export default LocalUserManagementStore; |