From e6e11120601cb48fd6165a5f7aadc8397c9e0a25 Mon Sep 17 00:00:00 2001 From: WorkClub Automation Date: Sat, 21 Mar 2026 13:32:53 +0100 Subject: [PATCH] Add debug logging for admin status detection --- frontend/src/auth/auth.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/frontend/src/auth/auth.ts b/frontend/src/auth/auth.ts index 9a02704..257f16f 100644 --- a/frontend/src/auth/auth.ts +++ b/frontend/src/auth/auth.ts @@ -79,9 +79,13 @@ export const { handlers, signIn, signOut, auth } = NextAuth({ const payload = JSON.parse(Buffer.from((token.accessToken as string).split('.')[1], 'base64').toString()); const roles = (payload.realm_access?.roles as string[]) || []; token.isAdmin = roles.includes('admin'); - } catch { + console.log('[Auth Debug] Checking admin status:', { roles, isAdmin: token.isAdmin }); + } catch (e) { + console.error('[Auth Debug] Failed to check admin status:', e); token.isAdmin = false; } + } else { + console.log('[Auth Debug] No access token available'); } return token },