yarm6mesq: Refresh expired tokens and revoke on sign-out
This commit is contained in:
@@ -30,6 +30,19 @@ export async function loadSession(f: Fetch = fetch): Promise<Person | null> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* DELETE /api/session: sign out. Resolves once the server has cleared the
|
||||
* session and cookie. A failed request still returns the UI to signed-out,
|
||||
* because the local session view is no longer trustworthy.
|
||||
*/
|
||||
export async function signOut(f: Fetch = fetch): Promise<void> {
|
||||
try {
|
||||
await f("/api/session", { method: "DELETE", credentials: "same-origin", cache: "no-store" });
|
||||
} catch {
|
||||
// Ignore: the caller returns to the sign-in screen regardless.
|
||||
}
|
||||
}
|
||||
|
||||
export type SignInResult = { ok: true; person: Person } | { ok: false; message: string };
|
||||
|
||||
/** POST /api/session. A 401 is always the one wrong-credentials message. */
|
||||
|
||||
Reference in New Issue
Block a user