feat: add admin auth session expiration handling

Add auth session utilities and event handling in src/lib/auth-session.ts
Integrate auth expiration checks in API request and uploadMediaAsset functions
Update App component to subscribe to auth expired events and update auth state
Add test suite for the auth session utility function
Adjust maintenance grid CSS layout
Remove unused UI components and imports in StructurePage
This commit is contained in:
duanshuwen
2026-07-11 20:49:12 +08:00
parent 5b089875b3
commit 96c005d479
6 changed files with 46 additions and 21 deletions

View File

@@ -0,0 +1,11 @@
import assert from "node:assert/strict";
import test from "node:test";
import { shouldExpireAdminSession } from "../src/lib/auth-session.js";
test("only token-backed 401 responses expire the admin session", () => {
assert.equal(shouldExpireAdminSession(401, true), true);
assert.equal(shouldExpireAdminSession(401, false), false);
assert.equal(shouldExpireAdminSession(403, true), false);
assert.equal(shouldExpireAdminSession(500, true), false);
});