summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/router/index.js10
-rw-r--r--src/store/modules/Authentication/AuthenticanStore.js7
-rw-r--r--src/views/Login/Login.vue5
3 files changed, 9 insertions, 13 deletions
diff --git a/src/router/index.js b/src/router/index.js
index bcb2c7a2..5b6d9099 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -42,13 +42,9 @@ router.beforeEach((to, from, next) => {
if (!currentUserRole && store.getters['authentication/isLoggedIn']) {
// invoke API call to get the role ID
let username = localStorage.getItem('storedUsername');
- store.dispatch('authentication/getUserInfo', username).then((response) => {
- if (response?.RoleId) {
- // set role ID
- store.commit('global/setPrivilege', response.RoleId);
- // allow the route to continue
- allowRouterToNavigate(to, next, response.RoleId);
- }
+ store.dispatch('authentication/getUserInfo', username).then(() => {
+ let currentUserRole = store.getters['global/userPrivilege'];
+ allowRouterToNavigate(to, next, currentUserRole);
});
} else {
allowRouterToNavigate(to, next, currentUserRole);
diff --git a/src/store/modules/Authentication/AuthenticanStore.js b/src/store/modules/Authentication/AuthenticanStore.js
index 0dca1832..57270159 100644
--- a/src/store/modules/Authentication/AuthenticanStore.js
+++ b/src/store/modules/Authentication/AuthenticanStore.js
@@ -61,10 +61,13 @@ const AuthenticationStore = {
.then(() => router.push('/login'))
.catch((error) => console.log(error));
},
- getUserInfo(_, username) {
+ getUserInfo({ commit }, username) {
return api
.get(`/redfish/v1/AccountService/Accounts/${username}`)
- .then(({ data }) => data)
+ .then(({ data }) => {
+ commit('global/setPrivilege', data.RoleId, { root: true });
+ return data;
+ })
.catch((error) => console.log(error));
},
resetStoreState({ state }) {
diff --git a/src/views/Login/Login.vue b/src/views/Login/Login.vue
index 96b4c9e8..db475c56 100644
--- a/src/views/Login/Login.vue
+++ b/src/views/Login/Login.vue
@@ -124,15 +124,12 @@ export default {
this.$store.commit('global/setLanguagePreference', i18n.locale);
return this.$store.dispatch('authentication/getUserInfo', username);
})
- .then(({ PasswordChangeRequired, RoleId }) => {
+ .then(({ PasswordChangeRequired }) => {
if (PasswordChangeRequired) {
this.$router.push('/change-password');
} else {
this.$router.push('/');
}
- if (RoleId) {
- this.$store.commit('global/setPrivilege', RoleId);
- }
})
.catch((error) => console.log(error))
.finally(() => (this.disableSubmitButton = false));