Add debug logging to auth-guard to trace isAdmin issue
This commit is contained in:
@@ -60,6 +60,13 @@ export function AuthGuard({ children }: { children: ReactNode }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const isAdmin = data?.user?.isAdmin;
|
const isAdmin = data?.user?.isAdmin;
|
||||||
|
|
||||||
|
// Debug: Log auth state
|
||||||
|
console.log('[AuthGuard Debug] status:', status);
|
||||||
|
console.log('[AuthGuard Debug] isAdmin:', isAdmin);
|
||||||
|
console.log('[AuthGuard Debug] data?.user:', data?.user);
|
||||||
|
console.log('[AuthGuard Debug] clubs.length:', clubs.length);
|
||||||
|
|
||||||
if (clubs.length === 0 && status === 'authenticated' && !isAdmin) {
|
if (clubs.length === 0 && status === 'authenticated' && !isAdmin) {
|
||||||
const handleSwitchAccount = () => {
|
const handleSwitchAccount = () => {
|
||||||
const keycloakLogoutUrl = `${process.env.NEXT_PUBLIC_KEYCLOAK_ISSUER || 'http://localhost:8080/realms/workclub'}/protocol/openid-connect/logout?redirect_uri=${encodeURIComponent(window.location.origin + '/login')}`;
|
const keycloakLogoutUrl = `${process.env.NEXT_PUBLIC_KEYCLOAK_ISSUER || 'http://localhost:8080/realms/workclub'}/protocol/openid-connect/logout?redirect_uri=${encodeURIComponent(window.location.origin + '/login')}`;
|
||||||
|
|||||||
Reference in New Issue
Block a user