From b440616c23b61166ae6d87839a70eec31bdca235 Mon Sep 17 00:00:00 2001 From: Sandeepa Singh Date: Mon, 26 Jul 2021 15:05:39 +0530 Subject: IA update: Update access and control section This is the fifth commit of the information architecture changes and has the following changes: - The icon for access and control has been updated - Access and control section has been updated to security and access section - Security settings page has been updated to policies page and moved to security and access section - Client sessions page has been updated to sessions page - Local user management page has been updated to user management page - SSL certificates page has been updated to certificates page Signed-off-by: Sandeepa Singh Change-Id: Ie93cee9002742ecf7d33615636f4f159f4395fc4 --- .../AccessControl/LocalUserMangementStore.js | 325 --------------------- 1 file changed, 325 deletions(-) delete mode 100644 src/store/modules/AccessControl/LocalUserMangementStore.js (limited to 'src/store/modules/AccessControl/LocalUserMangementStore.js') diff --git a/src/store/modules/AccessControl/LocalUserMangementStore.js b/src/store/modules/AccessControl/LocalUserMangementStore.js deleted file mode 100644 index 6bc6ec5d..00000000 --- a/src/store/modules/AccessControl/LocalUserMangementStore.js +++ /dev/null @@ -1,325 +0,0 @@ -import api, { getResponseCount } from '@/store/api'; -import i18n from '@/i18n'; - -const LocalUserManagementStore = { - namespaced: true, - state: { - allUsers: [], - accountRoles: [], - accountLockoutDuration: null, - accountLockoutThreshold: null, - accountMinPasswordLength: null, - accountMaxPasswordLength: null, - }, - getters: { - allUsers(state) { - return state.allUsers; - }, - accountRoles(state) { - return state.accountRoles; - }, - accountSettings(state) { - return { - lockoutDuration: state.accountLockoutDuration, - lockoutThreshold: state.accountLockoutThreshold, - }; - }, - accountPasswordRequirements(state) { - return { - minLength: state.accountMinPasswordLength, - maxLength: state.accountMaxPasswordLength, - }; - }, - }, - mutations: { - setUsers(state, allUsers) { - state.allUsers = allUsers; - }, - setAccountRoles(state, accountRoles) { - state.accountRoles = accountRoles; - }, - setLockoutDuration(state, lockoutDuration) { - state.accountLockoutDuration = lockoutDuration; - }, - setLockoutThreshold(state, lockoutThreshold) { - state.accountLockoutThreshold = lockoutThreshold; - }, - setAccountMinPasswordLength(state, minPasswordLength) { - state.accountMinPasswordLength = minPasswordLength; - }, - 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); - commit('setUsers', userData); - }) - .catch((error) => { - console.log(error); - const message = i18n.t( - 'pageLocalUserManagement.toast.errorLoadUsers' - ); - throw new Error(message); - }); - }, - getAccountSettings({ commit }) { - api - .get('/redfish/v1/AccountService') - .then(({ data }) => { - commit('setLockoutDuration', data.AccountLockoutDuration); - commit('setLockoutThreshold', data.AccountLockoutThreshold); - commit('setAccountMinPasswordLength', data.MinPasswordLength); - commit('setAccountMaxPasswordLength', data.MaxPasswordLength); - }) - .catch((error) => { - console.log(error); - const message = i18n.t( - 'pageLocalUserManagement.toast.errorLoadAccountSettings' - ); - throw new Error(message); - }); - }, - getAccountRoles({ commit }) { - api - .get('/redfish/v1/AccountService/Roles') - .then(({ data: { Members = [] } = {} }) => { - const roles = Members.map((role) => { - return role['@odata.id'].split('/').pop(); - }); - commit('setAccountRoles', roles); - }) - .catch((error) => console.log(error)); - }, - async createUser({ dispatch }, { username, password, privilege, status }) { - const data = { - UserName: username, - Password: password, - RoleId: privilege, - Enabled: status, - }; - return await api - .post('/redfish/v1/AccountService/Accounts', data) - .then(() => dispatch('getUsers')) - .then(() => - i18n.t('pageLocalUserManagement.toast.successCreateUser', { - username, - }) - ) - .catch((error) => { - console.log(error); - const message = i18n.t( - 'pageLocalUserManagement.toast.errorCreateUser', - { username } - ); - throw new Error(message); - }); - }, - async updateUser( - { dispatch }, - { originalUsername, username, password, privilege, status, locked } - ) { - const data = {}; - if (username) data.UserName = username; - if (password) data.Password = password; - if (privilege) data.RoleId = privilege; - if (status !== undefined) data.Enabled = status; - if (locked !== undefined) data.Locked = locked; - return await api - .patch(`/redfish/v1/AccountService/Accounts/${originalUsername}`, data) - .then(() => dispatch('getUsers')) - .then(() => - i18n.t('pageLocalUserManagement.toast.successUpdateUser', { - username: originalUsername, - }) - ) - .catch((error) => { - console.log(error); - const message = i18n.t( - 'pageLocalUserManagement.toast.errorUpdateUser', - { username: originalUsername } - ); - throw new Error(message); - }); - }, - async deleteUser({ dispatch }, username) { - return await api - .delete(`/redfish/v1/AccountService/Accounts/${username}`) - .then(() => dispatch('getUsers')) - .then(() => - i18n.t('pageLocalUserManagement.toast.successDeleteUser', { - username, - }) - ) - .catch((error) => { - console.log(error); - const message = i18n.t( - 'pageLocalUserManagement.toast.errorDeleteUser', - { username } - ); - throw new Error(message); - }); - }, - async deleteUsers({ dispatch }, users) { - const promises = users.map(({ username }) => { - return api - .delete(`/redfish/v1/AccountService/Accounts/${username}`) - .catch((error) => { - console.log(error); - return error; - }); - }); - return await api - .all(promises) - .then((response) => { - dispatch('getUsers'); - return response; - }) - .then( - api.spread((...responses) => { - const { successCount, errorCount } = getResponseCount(responses); - let toastMessages = []; - - if (successCount) { - const message = i18n.tc( - 'pageLocalUserManagement.toast.successBatchDelete', - successCount - ); - toastMessages.push({ type: 'success', message }); - } - - if (errorCount) { - const message = i18n.tc( - 'pageLocalUserManagement.toast.errorBatchDelete', - errorCount - ); - toastMessages.push({ type: 'error', message }); - } - - return toastMessages; - }) - ); - }, - async enableUsers({ dispatch }, users) { - const data = { - Enabled: true, - }; - const promises = users.map(({ username }) => { - return api - .patch(`/redfish/v1/AccountService/Accounts/${username}`, data) - .catch((error) => { - console.log(error); - return error; - }); - }); - return await api - .all(promises) - .then((response) => { - dispatch('getUsers'); - return response; - }) - .then( - api.spread((...responses) => { - const { successCount, errorCount } = getResponseCount(responses); - let toastMessages = []; - - if (successCount) { - const message = i18n.tc( - 'pageLocalUserManagement.toast.successBatchEnable', - successCount - ); - toastMessages.push({ type: 'success', message }); - } - - if (errorCount) { - const message = i18n.tc( - 'pageLocalUserManagement.toast.errorBatchEnable', - errorCount - ); - toastMessages.push({ type: 'error', message }); - } - - return toastMessages; - }) - ); - }, - async disableUsers({ dispatch }, users) { - const data = { - Enabled: false, - }; - const promises = users.map(({ username }) => { - return api - .patch(`/redfish/v1/AccountService/Accounts/${username}`, data) - .catch((error) => { - console.log(error); - return error; - }); - }); - return await api - .all(promises) - .then((response) => { - dispatch('getUsers'); - return response; - }) - .then( - api.spread((...responses) => { - const { successCount, errorCount } = getResponseCount(responses); - let toastMessages = []; - - if (successCount) { - const message = i18n.tc( - 'pageLocalUserManagement.toast.successBatchDisable', - successCount - ); - toastMessages.push({ type: 'success', message }); - } - - if (errorCount) { - const message = i18n.tc( - 'pageLocalUserManagement.toast.errorBatchDisable', - errorCount - ); - toastMessages.push({ type: 'error', message }); - } - - return toastMessages; - }) - ); - }, - async saveAccountSettings( - { dispatch }, - { lockoutThreshold, lockoutDuration } - ) { - const data = {}; - if (lockoutThreshold !== undefined) { - data.AccountLockoutThreshold = lockoutThreshold; - } - if (lockoutDuration !== undefined) { - data.AccountLockoutDuration = lockoutDuration; - } - - return await api - .patch('/redfish/v1/AccountService', data) - //GET new settings to update view - .then(() => dispatch('getAccountSettings')) - .then(() => i18n.t('pageLocalUserManagement.toast.successSaveSettings')) - .catch((error) => { - console.log(error); - const message = i18n.t( - 'pageLocalUserManagement.toast.errorSaveSettings' - ); - throw new Error(message); - }); - }, - }, -}; - -export default LocalUserManagementStore; -- cgit v1.2.3