From 1440eae3a2e60a0a8c0bdae2d12f83a3b2d8ba73 Mon Sep 17 00:00:00 2001 From: alma Date: Fri, 18 Apr 2025 14:41:11 +0200 Subject: [PATCH] session correction sidebar items 4 --- app/api/auth/[...nextauth]/route.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/api/auth/[...nextauth]/route.ts b/app/api/auth/[...nextauth]/route.ts index cb8e56b7..c5a0caad 100644 --- a/app/api/auth/[...nextauth]/route.ts +++ b/app/api/auth/[...nextauth]/route.ts @@ -93,8 +93,12 @@ export const authOptions: NextAuthOptions = { profile }); + // Get roles from the token claims + const roles = profile.roles || []; + console.log('Raw roles from Keycloak:', roles); + // Clean up roles by removing ROLE_ prefix and converting to lowercase - const cleanRoles = (profile.roles ?? []).map(role => + const cleanRoles = roles.map(role => role.replace(/^ROLE_/, '').toLowerCase() );