fix(auth): isolate client cache by session

This commit is contained in:
lingniu
2026-07-16 04:26:20 +08:00
parent b39917d9d6
commit 6b4a0726b2
6 changed files with 131 additions and 10 deletions

View File

@@ -1,4 +1,5 @@
const TOKEN_KEY = 'vehicle-platform.access-token';
export const PLATFORM_UNAUTHORIZED_EVENT = 'vehicle-platform:unauthorized';
export type PlatformRole = 'viewer' | 'operator' | 'admin';
@@ -22,6 +23,10 @@ export function clearAccessToken() {
window.sessionStorage.removeItem(TOKEN_KEY);
}
export function notifyUnauthorizedSession() {
window.dispatchEvent(new Event(PLATFORM_UNAUTHORIZED_EVENT));
}
export function canOperate(session: PlatformSession) {
return session.role === 'operator' || session.role === 'admin';
}