diff --git a/src/store/modules/auth/index.ts b/src/store/modules/auth/index.ts index 7bd7c59..6015264 100644 --- a/src/store/modules/auth/index.ts +++ b/src/store/modules/auth/index.ts @@ -88,7 +88,10 @@ export const useAuthStore = defineStore(SetupStoreId.Auth, () => { // 1. stored in the localStorage, the later requests need it in headers localStg.set('token', loginToken.token); // localStg.set('refreshToken', loginToken.refreshToken); - localStg.set('namespaceId', loginToken.namespaceIds[0].uniqueId); + const namespaceId = localStg.get('namespaceId'); + if (!namespaceId || !loginToken.namespaceIds.map(item => item.uniqueId.includes(namespaceId))) { + localStg.set('namespaceId', loginToken.namespaceIds[0].uniqueId); + } const { data: info, error } = await fetchGetUserInfo(); diff --git a/src/store/modules/auth/shared.ts b/src/store/modules/auth/shared.ts index 3cd8d3a..5d215c4 100644 --- a/src/store/modules/auth/shared.ts +++ b/src/store/modules/auth/shared.ts @@ -31,6 +31,6 @@ export function getUserInfo() { export function clearAuthStorage() { localStg.remove('token'); // localStg.remove('refreshToken'); - localStg.remove('namespaceId'); + // localStg.remove('namespaceId'); localStg.remove('userInfo'); }