Add debug logging for admin status detection
This commit is contained in:
@@ -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 payload = JSON.parse(Buffer.from((token.accessToken as string).split('.')[1], 'base64').toString());
|
||||||
const roles = (payload.realm_access?.roles as string[]) || [];
|
const roles = (payload.realm_access?.roles as string[]) || [];
|
||||||
token.isAdmin = roles.includes('admin');
|
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;
|
token.isAdmin = false;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
console.log('[Auth Debug] No access token available');
|
||||||
}
|
}
|
||||||
return token
|
return token
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user