session correction sidebar items 6

This commit is contained in:
alma 2025-04-18 14:49:22 +02:00
parent 136627f226
commit ea05b15276

View File

@ -95,11 +95,12 @@ export const authOptions: NextAuthOptions = {
profile(profile) { profile(profile) {
console.log('Keycloak profile:', { console.log('Keycloak profile:', {
rawRoles: profile.roles, rawRoles: profile.roles,
realmAccess: profile.realm_access,
profile profile
}); });
// Get roles from the token claims // Get roles from realm_access
const roles = profile.roles || []; const roles = profile.realm_access?.roles || [];
console.log('Raw roles from Keycloak:', roles); console.log('Raw roles from Keycloak:', roles);
// Clean up roles by removing ROLE_ prefix and converting to lowercase // Clean up roles by removing ROLE_ prefix and converting to lowercase
@ -131,7 +132,8 @@ export const authOptions: NextAuthOptions = {
const keycloakProfile = profile as KeycloakProfile; const keycloakProfile = profile as KeycloakProfile;
console.log('JWT callback profile:', { console.log('JWT callback profile:', {
rawRoles: keycloakProfile.roles, rawRoles: keycloakProfile.roles,
profile: keycloakProfile profile: keycloakProfile,
token: account.access_token
}); });
// Clean up roles by removing ROLE_ prefix and converting to lowercase // Clean up roles by removing ROLE_ prefix and converting to lowercase