update frontend to match new user-info endpoint
All checks were successful
Build Container / Build Container (push) Successful in 1m27s
All checks were successful
Build Container / Build Container (push) Successful in 1m27s
This commit is contained in:
parent
99668e2a33
commit
2e1742279d
3 changed files with 22 additions and 28 deletions
|
|
@ -1,3 +1,3 @@
|
||||||
# Update schema
|
# 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`
|
||||||
|
|
|
||||||
|
|
@ -127,6 +127,21 @@ export interface paths {
|
||||||
export type webhooks = Record<string, never>;
|
export type webhooks = Record<string, never>;
|
||||||
export interface components {
|
export interface components {
|
||||||
schemas: {
|
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 */
|
||||||
HTTPValidationError: {
|
HTTPValidationError: {
|
||||||
/** Detail */
|
/** Detail */
|
||||||
|
|
@ -193,20 +208,6 @@ export interface components {
|
||||||
*/
|
*/
|
||||||
activity_state: "unknown" | "locking" | "unlocking" | "stable";
|
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 */
|
||||||
ValidationError: {
|
ValidationError: {
|
||||||
/** Location */
|
/** Location */
|
||||||
|
|
@ -244,16 +245,7 @@ export interface operations {
|
||||||
[name: string]: unknown;
|
[name: string]: unknown;
|
||||||
};
|
};
|
||||||
content: {
|
content: {
|
||||||
"application/json": components["schemas"]["UserStatus"];
|
"application/json": components["schemas"]["ApiUser"];
|
||||||
};
|
|
||||||
};
|
|
||||||
/** @description Unauthorized */
|
|
||||||
401: {
|
|
||||||
headers: {
|
|
||||||
[name: string]: unknown;
|
|
||||||
};
|
|
||||||
content: {
|
|
||||||
"application/json": components["schemas"]["HttpProblemDetail"];
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -93,13 +93,15 @@ async function checkUser() {
|
||||||
const {data: userInfo} = await getUserInfo({})
|
const {data: userInfo} = await getUserInfo({})
|
||||||
|
|
||||||
apiError.current = null
|
apiError.current = null
|
||||||
auth.authenticated = true
|
auth.authenticated = !userInfo.is_anonymous
|
||||||
auth.authorized = userInfo.is_authorized
|
auth.authorized = userInfo.may_operate_locks
|
||||||
auth.until = userInfo.guaranteed_session_until ? new Date(userInfo.guaranteed_session_until) : null
|
auth.until = userInfo.guaranteed_session_until ? new Date(userInfo.guaranteed_session_until) : null
|
||||||
auth.username = userInfo.username ?? ""
|
auth.username = userInfo.username ?? ""
|
||||||
auth.recentLogout = false
|
auth.recentLogout = false
|
||||||
|
|
||||||
|
if (auth.authenticated) {
|
||||||
triggerAuthTimeout()
|
triggerAuthTimeout()
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// check which operation threw the exception
|
// check which operation threw the exception
|
||||||
if (e instanceof getUserInfo.Error) {
|
if (e instanceof getUserInfo.Error) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue