From 2e1742279d919400bfbd976ce04f3642db7ab9aa Mon Sep 17 00:00:00 2001 From: kritzl Date: Fri, 29 May 2026 09:57:04 +0200 Subject: [PATCH] update frontend to match new user-info endpoint --- app/src/api/README.md | 2 +- app/src/api/schema.ts | 40 ++++++++++++++++------------------------ app/src/assets/main.ts | 8 +++++--- 3 files changed, 22 insertions(+), 28 deletions(-) diff --git a/app/src/api/README.md b/app/src/api/README.md index 256986b..6dc22f0 100644 --- a/app/src/api/README.md +++ b/app/src/api/README.md @@ -1,3 +1,3 @@ # Update schema -`pnpm dlx openapi-typescript http://localhost:8000/openapi.json -o ./schema.ts` +`pnpm dlx openapi-typescript http://localhost:8000/api/openapi.json -o ./schema.ts` diff --git a/app/src/api/schema.ts b/app/src/api/schema.ts index 4f4b938..50495c9 100644 --- a/app/src/api/schema.ts +++ b/app/src/api/schema.ts @@ -127,6 +127,21 @@ export interface paths { export type webhooks = Record; export interface components { schemas: { + /** ApiUser */ + ApiUser: { + /** Is Anonymous */ + is_anonymous: boolean; + /** Is Ccchh User */ + is_ccchh_user: boolean; + /** Is Token User */ + is_token_user: boolean; + /** May Operate Locks */ + may_operate_locks: boolean; + /** Username */ + username: string; + /** Guaranteed Session Until */ + guaranteed_session_until: string | null; + }; /** HTTPValidationError */ HTTPValidationError: { /** Detail */ @@ -193,20 +208,6 @@ export interface components { */ activity_state: "unknown" | "locking" | "unlocking" | "stable"; }; - /** UserStatus */ - UserStatus: { - /** Is Authorized */ - is_authorized: boolean; - /** - * Guaranteed Session Until - * Format: date-time - */ - guaranteed_session_until: string; - /** Username */ - username: string; - /** Ccchh Roles */ - ccchh_roles: string[]; - }; /** ValidationError */ ValidationError: { /** Location */ @@ -244,16 +245,7 @@ export interface operations { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["UserStatus"]; - }; - }; - /** @description Unauthorized */ - 401: { - headers: { - [name: string]: unknown; - }; - content: { - "application/json": components["schemas"]["HttpProblemDetail"]; + "application/json": components["schemas"]["ApiUser"]; }; }; }; diff --git a/app/src/assets/main.ts b/app/src/assets/main.ts index 205f64f..82594c6 100644 --- a/app/src/assets/main.ts +++ b/app/src/assets/main.ts @@ -93,13 +93,15 @@ async function checkUser() { const {data: userInfo} = await getUserInfo({}) apiError.current = null - auth.authenticated = true - auth.authorized = userInfo.is_authorized + auth.authenticated = !userInfo.is_anonymous + auth.authorized = userInfo.may_operate_locks auth.until = userInfo.guaranteed_session_until ? new Date(userInfo.guaranteed_session_until) : null auth.username = userInfo.username ?? "" auth.recentLogout = false - triggerAuthTimeout() + if (auth.authenticated) { + triggerAuthTimeout() + } } catch (e) { // check which operation threw the exception if (e instanceof getUserInfo.Error) {