Admin: gebruikerslijst blijft actueel, sessie blijft behouden bij tijdelijke refresh-fouten
- Refresh wist de sessie alleen nog bij 400/401/403; 429/5xx/netwerkfout behoudt hem (opstart: rustig opnieuw proberen met backoff, anders gast zonder het cookie te raken) - Refresh is single-flight (opstart, 401-interceptor, profiel delen een lopende aanvraag) - GET-verzoeken met cache: no-store; gebruikerslijst: refetch bij focus en poll 45 s; sessie ververst als de eigen rol in de lijst afwijkt Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -99,10 +99,18 @@ export class ApiClient {
|
||||
|
||||
// 401 intercept: try a single cookie-based refresh, then retry once (BR-U1-04).
|
||||
if (response.status === 401 && !options.skipAuthRefresh && this.refreshHandler !== null) {
|
||||
const newToken = await this.refreshHandler();
|
||||
let newToken: string | null = null;
|
||||
let rejected = false;
|
||||
try {
|
||||
newToken = await this.refreshHandler();
|
||||
rejected = newToken === null;
|
||||
} catch {
|
||||
// Transient (rate limit, restart, network): the session is not known to be gone, so it is not
|
||||
// cleared; the caller gets the original 401.
|
||||
}
|
||||
if (newToken !== null) {
|
||||
response = await this.rawFetch(path, options);
|
||||
} else {
|
||||
} else if (rejected) {
|
||||
this.authFailureHandler?.();
|
||||
}
|
||||
}
|
||||
@@ -126,6 +134,8 @@ export class ApiClient {
|
||||
...rest,
|
||||
headers: finalHeaders,
|
||||
credentials: 'include',
|
||||
// A list read after a change must come from the server, never from an intermediate cache.
|
||||
...(rest.method === 'GET' ? { cache: 'no-store' as const } : {}),
|
||||
body: body !== undefined && body !== null ? JSON.stringify(body) : undefined,
|
||||
});
|
||||
} catch (cause) {
|
||||
|
||||
Reference in New Issue
Block a user