feat(auth): clear session resource caches on logout to prevent data leakage
This commit is contained in:
@@ -8,6 +8,16 @@ import { reloadFontFromStorage } from '@/composables/useFont'
|
|||||||
import { reloadThemeFromStorage } from '@/composables/useTheme'
|
import { reloadThemeFromStorage } from '@/composables/useTheme'
|
||||||
import { resetMigrationLatch } from '@/composables/preferenceStorage'
|
import { resetMigrationLatch } from '@/composables/preferenceStorage'
|
||||||
import { BUILTIN_QUICK_ANSWER_ID } from '@/api/agent'
|
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.
|
// Per-user UI preferences are namespaced by user id in localStorage.
|
||||||
// Reload them whenever the active user changes.
|
// Reload them whenever the active user changes.
|
||||||
@@ -380,6 +390,7 @@ export const useAuthStore = defineStore('auth', () => {
|
|||||||
allTenants.value = []
|
allTenants.value = []
|
||||||
memberships.value = []
|
memberships.value = []
|
||||||
pendingInvitationCount.value = 0
|
pendingInvitationCount.value = 0
|
||||||
|
clearSessionResourceCaches()
|
||||||
|
|
||||||
// 清空localStorage
|
// 清空localStorage
|
||||||
localStorage.removeItem('weknora_user')
|
localStorage.removeItem('weknora_user')
|
||||||
|
|||||||
@@ -170,9 +170,13 @@ export const useEditorResourcesStore = defineStore('editorResources', () => {
|
|||||||
tenantRetrievalConfig.value = null
|
tenantRetrievalConfig.value = null
|
||||||
parserEngines.value = []
|
parserEngines.value = []
|
||||||
systemInfo.value = null
|
systemInfo.value = null
|
||||||
|
inflight.clear()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
keys.forEach((k) => delete loadedAt.value[k])
|
keys.forEach((k) => {
|
||||||
|
delete loadedAt.value[k]
|
||||||
|
inflight.delete(k)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user