fix(auth): isolate client cache by session
This commit is contained in:
@@ -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';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user