Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: request fetchIamPolicy after login (#13135)

Liu Jia94af3a229aa
diff --git a/frontend/src/App.vue b/frontend/src/App.vue
index 244e705677..b82c47dbbd 100644
--- a/frontend/src/App.vue
+++ b/frontend/src/App.vue
@@ -40,7 +40,7 @@ import {
import { NSpin } from "naive-ui";
import { ServerError } from "nice-grpc-common";
import { ClientError, Status } from "nice-grpc-web";
-import { onErrorCaptured, onMounted, ref, watchEffect } from "vue";
+import { onErrorCaptured, onMounted, ref } from "vue";
import { watch } from "vue";
import { useRoute, useRouter } from "vue-router";
import Watermark from "@/components/misc/Watermark.vue";
@@ -56,7 +56,6 @@ import {
useAuthStore,
useNotificationStore,
useSubscriptionV1Store,
- useWorkspaceV1Store,
} from "./store";
import { isDev } from "./utils";
@@ -118,12 +117,6 @@ onMounted(async () => {
}, CHECK_LOGGEDIN_STATE_DURATION);
});
-watchEffect(async () => {
- if (authStore.currentUserId) {
- await useWorkspaceV1Store().fetchIamPolicy();
- }
-});
-
onErrorCaptured((error: any /* , _, info */) => {
// Handle grpc request error.
// It looks like: `{"path":"/bytebase.v1.AuthService/Login","code":2,"details":"Response closed without headers"}`
diff --git a/frontend/src/store/modules/auth.ts b/frontend/src/store/modules/auth.ts
index dee9ef8c25..d8095daf0e 100644
--- a/frontend/src/store/modules/auth.ts
+++ b/frontend/src/store/modules/auth.ts
@@ -10,7 +10,7 @@ import type {
} from "@/types/proto/v1/auth_service";
import { UserType } from "@/types/proto/v1/auth_service";
import { getIntCookie } from "@/utils";
-import { useUserStore } from ".";
+import { useUserStore, useWorkspaceV1Store } from ".";
export const useAuthStore = defineStore("auth_v1", () => {
const userStore = useUserStore();
@@ -38,6 +38,7 @@ export const useAuthStore = defineStore("auth_v1", () => {
currentUserId.value = getIntCookie("user");
if (currentUserId.value) {
await useUserStore().getOrFetchUserById(String(currentUserId.value));
+ await useWorkspaceV1Store().fetchIamPolicy();
}
};
@@ -55,6 +56,7 @@ export const useAuthStore = defineStore("auth_v1", () => {
password: signupInfo.password,
web: true,
});
+ await useWorkspaceV1Store().fetchIamPolicy();
};
const logout = async () => {
@@ -89,6 +91,7 @@ export const useAuthStore = defineStore("auth_v1", () => {
String(currentUserId.value),
true // silent
);
+ await useWorkspaceV1Store().fetchIamPolicy();
}
};
diff --git a/frontend/src/views/OAuthCallback.vue b/frontend/src/views/OAuthCallback.vue
index c291e7205c..4412e880e4 100644
--- a/frontend/src/views/OAuthCallback.vue
+++ b/frontend/src/views/OAuthCallback.vue
@@ -18,7 +18,7 @@ import { parse } from "qs";
import { onMounted, reactive } from "vue";
import { useRoute, useRouter } from "vue-router";
import { AUTH_MFA_MODULE, AUTH_SIGNIN_MODULE } from "@/router/auth";
-import { useAuthStore } from "@/store";
+import { useAuthStore, useWorkspaceV1Store } from "@/store";
import type { OAuthState, OAuthWindowEventPayload } from "../types";
interface LocalState {
@@ -95,6 +95,7 @@ const triggerAuthCallback = async () => {
},
web: true,
});
+ await useWorkspaceV1Store().fetchIamPolicy();
if (mfaTempToken) {
const route = router.resolve({
name: AUTH_MFA_MODULE,