Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
Refresh the user state if we change proactively or it’s been changed remotely.
天舟814771638d50
diff --git a/frontend/src/components/ProvideContext.vue b/frontend/src/components/ProvideContext.vueindex 4e9b9b0f8a..ef38113625 100644--- a/frontend/src/components/ProvideContext.vue+++ b/frontend/src/components/ProvideContext.vue@@ -22,6 +22,10 @@ export default {store.dispatch("instance/fetchInstanceList"),store.dispatch("uistate/restoreState"),]);++ // Refresh the user after fetchRoleMappingList / fetchPrincipalList.+ // The user info may change remoted and thus we need to refresh both in-memory and local cache state.+ store.dispatch("auth/refreshUser");},};</script>diff --git a/frontend/src/store/modules/auth.ts b/frontend/src/store/modules/auth.tsindex 5dc66e2a13..9e8ad0e565 100644--- a/frontend/src/store/modules/auth.ts+++ b/frontend/src/store/modules/auth.ts@@ -1,4 +1,5 @@import axios from "axios";+import isEqual from "lodash-es/isEqual";import {Principal,AuthState,@@ -26,14 +27,7 @@ const state: () => AuthState = () => ({const getters = {currentUser: (state: AuthState) => (): Principal => {- if (state.currentUser) {- return state.currentUser;- }- const user = localStorage.getItem("bb.auth.user");- if (user) {- return JSON.parse(user);- }- return GUEST;+ return state.currentUser;},};@@ -90,12 +84,23 @@ const actions = {commit("setCurrentUser", user);return user;}- return undefined;+ return GUEST;+ },++ async refreshUser({ commit, state, rootGetters }: any) {+ const refreshedUser = rootGetters["principal/principalById"](+ state.currentUser.id+ );+ if (!isEqual(refreshedUser, state.currentUser)) {+ localStorage.setItem("bb.auth.user", JSON.stringify(refreshedUser));+ commit("setCurrentUser", refreshedUser);+ }+ return refreshedUser;},async logout({ commit }: any) {localStorage.removeItem("bb.auth.user");- commit("setCurrentUser", undefined);+ commit("setCurrentUser", GUEST);return GUEST;},};diff --git a/frontend/src/views/ProfileDashboard.vue b/frontend/src/views/ProfileDashboard.vueindex c6f2c1eb56..2b936dddf6 100644--- a/frontend/src/views/ProfileDashboard.vue+++ b/frontend/src/views/ProfileDashboard.vue@@ -236,6 +236,7 @@ export default {.then(() => {state.editingPrincipal = undefined;state.editing = false;+ store.dispatch("auth/refreshUser");}).catch((error) => {console.log(error);