feat(auth): clear session resource caches on logout to prevent data leakage

This commit is contained in:
wizardchen
2026-06-15 17:43:53 +08:00
committed by lyingbug
parent cf0a64b88e
commit 90f8e8b390
2 changed files with 16 additions and 1 deletions
+11
View File
@@ -8,6 +8,16 @@ import { reloadFontFromStorage } from '@/composables/useFont'
import { reloadThemeFromStorage } from '@/composables/useTheme'
import { resetMigrationLatch } from '@/composables/preferenceStorage'
import { BUILTIN_QUICK_ANSWER_ID } from '@/api/agent'
import { useChatResourcesStore } from '@/stores/chatResources'
import { useEditorResourcesStore } from '@/stores/editorResources'
import { useOrganizationStore } from '@/stores/organization'
/** 登出时丢弃 Pinia 内的租户级资源缓存,避免 SPA 重登复用上一账号数据。 */
function clearSessionResourceCaches() {
useChatResourcesStore().invalidate()
useEditorResourcesStore().invalidate()
useOrganizationStore().clearState()
}
// Per-user UI preferences are namespaced by user id in localStorage.
// Reload them whenever the active user changes.
@@ -380,6 +390,7 @@ export const useAuthStore = defineStore('auth', () => {
allTenants.value = []
memberships.value = []
pendingInvitationCount.value = 0
clearSessionResourceCaches()
// 清空localStorage
localStorage.removeItem('weknora_user')