diff --git a/middleware/auth.ts b/middleware/auth.ts new file mode 100644 index 0000000..e67f788 --- /dev/null +++ b/middleware/auth.ts @@ -0,0 +1,7 @@ +export default defineNuxtRouteMiddleware(async () => { + const { loggedIn, login } = useOidcAuth(); + if (!loggedIn.value) { + console.warn("Not logged in"); + return login(); + } +}); diff --git a/nuxt.config.ts b/nuxt.config.ts index 03ea451..0ec7145 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -36,12 +36,12 @@ export default defineNuxtConfig({ }, }, session: { - expirationCheck: false, + expirationCheck: true, automaticRefresh: true, maxAge: 3600, }, middleware: { - globalMiddlewareEnabled: true, + globalMiddlewareEnabled: false, customLoginPage: false, }, }, diff --git a/pages/about.vue b/pages/about.vue index ad1b413..1856c63 100644 --- a/pages/about.vue +++ b/pages/about.vue @@ -1,4 +1,8 @@ - +