From aeb19816e67f6d3ffb1b37c95d813a25b8be1d7b Mon Sep 17 00:00:00 2001 From: Damian Celico Date: Thu, 24 Nov 2022 02:00:53 +0100 Subject: Added route restrictions based on user privilege This commit allows us to add 'exclusiveToRoles' field to route config files, with the list of roles that can access this resource, if needed. In this case, only Administrator can access Virtual-Media page and SOL console, and it is blocked for other users. Signed-off-by: Sivaprabu Ganesan Change-Id: Ibcee18bd92d97c34414ecaf2caf6af28070c5538 --- src/store/modules/Authentication/AuthenticanStore.js | 6 +++--- src/store/modules/GlobalStore.js | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'src/store') diff --git a/src/store/modules/Authentication/AuthenticanStore.js b/src/store/modules/Authentication/AuthenticanStore.js index 88fb54b8..02d6e637 100644 --- a/src/store/modules/Authentication/AuthenticanStore.js +++ b/src/store/modules/Authentication/AuthenticanStore.js @@ -58,10 +58,10 @@ const AuthenticationStore = { .then(() => router.go('/login')) .catch((error) => console.log(error)); }, - checkPasswordChangeRequired(_, username) { - api + getUserInfo(_, username) { + return api .get(`/redfish/v1/AccountService/Accounts/${username}`) - .then(({ data: { PasswordChangeRequired } }) => PasswordChangeRequired) + .then(({ data }) => data) .catch((error) => console.log(error)); }, resetStoreState({ state }) { diff --git a/src/store/modules/GlobalStore.js b/src/store/modules/GlobalStore.js index 95d7a083..74eb1e80 100644 --- a/src/store/modules/GlobalStore.js +++ b/src/store/modules/GlobalStore.js @@ -40,6 +40,7 @@ const GlobalStore = { : true, username: localStorage.getItem('storedUsername'), isAuthorized: true, + userPrivilege: null, }, getters: { assetTag: (state) => state.assetTag, @@ -51,6 +52,7 @@ const GlobalStore = { isUtcDisplay: (state) => state.isUtcDisplay, username: (state) => state.username, isAuthorized: (state) => state.isAuthorized, + userPrivilege: (state) => state.userPrivilege, }, mutations: { setAssetTag: (state, assetTag) => (state.assetTag = assetTag), @@ -70,6 +72,9 @@ const GlobalStore = { state.isAuthorized = true; }, 100); }, + setPrivilege: (state, privilege) => { + state.userPrivilege = privilege; + }, }, actions: { async getBmcTime({ commit }) { -- cgit v1.2.3