diff --git a/middleware/authentication.ts b/middleware/authentication.ts index 64c0af6..95ff241 100644 --- a/middleware/authentication.ts +++ b/middleware/authentication.ts @@ -19,7 +19,7 @@ export default defineNuxtRouteMiddleware(async (to) => { const user = await fetchUser(); setUser(user.value); } catch (error) { - // Directus auth failed, continue to check OIDC + // Directus auth failed, continue to check custom Keycloak auth } } @@ -28,12 +28,15 @@ export default defineNuxtRouteMiddleware(async (to) => { return; } - // Check OIDC auth (Keycloak) - const { user: oidcUser, loggedIn } = useOidcAuth(); - - if (loggedIn.value && oidcUser.value) { - // User authenticated with Keycloak via OIDC - return; + // Check custom Keycloak auth via session API + try { + const sessionData = await $fetch('/api/auth/session') as any; + if (sessionData.authenticated && sessionData.user) { + // User authenticated with Keycloak + return; + } + } catch (error) { + // Session check failed, continue to redirect } // No authentication found, redirect to login