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

@@ -55,7 +55,7 @@ import type {
VehicleServiceSummary,
VehicleRow
} from './types';
import { getAccessToken } from '../v2/auth/session';
import { getAccessToken, notifyUnauthorizedSession } from '../v2/auth/session';
export type RawFrameQuery = {
keyword?: string;
@@ -90,6 +90,7 @@ async function request<T>(path: string, init?: RequestInit): Promise<T> {
const requestInit = token ? { ...init, headers: withAuthorization(init?.headers, token) } : init;
const response = await fetch(path, requestInit);
if (!response.ok) {
if (response.status === 401 && token && path !== '/api/v2/session') notifyUnauthorizedSession();
throw new Error(await responseErrorMessage(response));
}
const envelope = (await response.json()) as ApiEnvelope<T>;