mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-03 17:41:51 +00:00
fix(plugin): clear brokered session state on logout
sessionStorage outlives a logout inside the same tab, so the keys stay readable after the next user signs in. They are namespaced by user id, which stops the new user's plugins from reading them, but the data is still sitting in the tab — the same reason logout already drops the appearance snapshot, the SW caches and the user-scoped offline DB. Purge them there too. Three things around it, from reading the handlers next to the new ones: - The inactive-plugin purge ran before the store was updated, so a sessionStorage failure cost us the plugin list we had just fetched. Commit first, purge after. - The session handlers answered without checking requestId, unlike confirm and geolocation — an answer the frame can never match is worth skipping. - The mock host threw plain Errors while the real bridge rejects with .code set, and checked the key before the trip scope where the host does the reverse, so a plugin's error handling could pass its tests and still break in the app.
This commit is contained in:
@@ -10,6 +10,7 @@ import { setAuthed } from '../sync/authGate'
|
||||
import { unregisterSyncTriggers } from '../sync/syncTriggers'
|
||||
import { useSystemNoticeStore } from './systemNoticeStore.js'
|
||||
import { clearAppearanceSnapshot } from '../theme/applyAppearance'
|
||||
import { clearAllPluginSessions } from './pluginStore'
|
||||
|
||||
interface AuthResponse {
|
||||
user: User
|
||||
@@ -195,6 +196,9 @@ export const useAuthStore = create<AuthState>()(
|
||||
// Drop the per-device appearance snapshot so the next user on a shared
|
||||
// browser doesn't get a pre-paint flash of this user's theme.
|
||||
clearAppearanceSnapshot()
|
||||
// Same reason for the brokered plugin session state: it is keyed by user id,
|
||||
// but sessionStorage outlives a logout within the tab.
|
||||
clearAllPluginSessions()
|
||||
// 4. Tell server to clear the httpOnly cookie (best-effort).
|
||||
await fetch('/api/auth/logout', { method: 'POST', credentials: 'include' }).catch(() => {})
|
||||
// 5. Clear service worker caches containing sensitive data.
|
||||
|
||||
Reference in New Issue
Block a user