From 8134e922842292ac5d822ac86c2ccdef9a2342a5 Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Mon, 11 Dec 2023 22:42:17 +0100 Subject: [PATCH] [backend/web-api] Make auth status response less confusing --- packages/backend/src/server/api/web/controllers/auth.ts | 3 +-- packages/backend/src/server/api/web/entities/auth.ts | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/backend/src/server/api/web/controllers/auth.ts b/packages/backend/src/server/api/web/controllers/auth.ts index 162a8881c..e54d2360c 100644 --- a/packages/backend/src/server/api/web/controllers/auth.ts +++ b/packages/backend/src/server/api/web/controllers/auth.ts @@ -21,8 +21,7 @@ export class AuthController { ): Promise { const user = me ? await UserHandler.getUser(me, me.id) : null; return { - authenticated: !!session?.active, - status: user && session?.active ? null : '2fa', + status: !user ? 'guest' : session?.active ? 'authenticated' : '2fa', token: session?.token ?? null, user: user, }; diff --git a/packages/backend/src/server/api/web/entities/auth.ts b/packages/backend/src/server/api/web/entities/auth.ts index 64fef2dd9..05f8f6aa6 100644 --- a/packages/backend/src/server/api/web/entities/auth.ts +++ b/packages/backend/src/server/api/web/entities/auth.ts @@ -1,8 +1,7 @@ import { UserResponse } from "@/server/api/web/entities/user.js"; export type AuthResponse = { - authenticated: boolean; - status: null | '2fa'; + status: 'guest' | 'authenticated' | '2fa'; token: string | null; user: UserResponse | null; }