fix: dashboard TOTP status always showing inactive

loadAuthData() didn't include totp_enabled or require_2fa in the
AuthData response. The frontend always saw undefined → false.

Now includes both fields from the database.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
BOHA
2026-03-23 20:31:06 +01:00
parent 33268b38ae
commit 456232cd82
2 changed files with 4 additions and 0 deletions

View File

@@ -59,6 +59,8 @@ async function loadAuthData(userId: number): Promise<AuthData | null> {
roleId: user.role_id, roleId: user.role_id,
roleName: user.roles?.name ?? null, roleName: user.roles?.name ?? null,
permissions, permissions,
totp_enabled: !!user.totp_enabled,
require_2fa: !!(await prisma.company_settings.findFirst({ select: { require_2fa: true } }))?.require_2fa,
}; };
} }

View File

@@ -51,6 +51,8 @@ export interface AuthData {
roleId: number | null; roleId: number | null;
roleName: string | null; roleName: string | null;
permissions: string[]; permissions: string[];
totp_enabled?: boolean;
require_2fa?: boolean;
} }
export interface JwtPayload { export interface JwtPayload {