Updates
This commit is contained in:
@@ -5,7 +5,7 @@ export type AppSession = {
|
||||
name: string;
|
||||
email: string;
|
||||
role: string;
|
||||
token: string;
|
||||
token?: string | null;
|
||||
tenant_id?: string | null;
|
||||
client_role?: string | null;
|
||||
user_id?: number | null;
|
||||
@@ -59,15 +59,16 @@ function createSessionStore(storageKey: string) {
|
||||
return {
|
||||
subscribe: store.subscribe,
|
||||
set(session: AppSession) {
|
||||
const storedSession = { ...session, token: null };
|
||||
if (browser) {
|
||||
localStorage.setItem(storageKey, JSON.stringify(session));
|
||||
localStorage.setItem(storageKey, JSON.stringify(storedSession));
|
||||
}
|
||||
store.set(session);
|
||||
store.set(storedSession);
|
||||
},
|
||||
clear() {
|
||||
if (browser) {
|
||||
localStorage.removeItem(storageKey);
|
||||
// Drop any cached API responses keyed to the old session token.
|
||||
// Drop any cached API responses keyed to the old session identity.
|
||||
// Imported lazily so this module stays free of api.ts side-effects.
|
||||
import('$lib/api').then(({ clearApiCache }) => clearApiCache()).catch(() => {});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user