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