diff --git a/middleware/auth.global.ts b/middleware/auth.global.ts index 6776533..74e42b9 100644 --- a/middleware/auth.global.ts +++ b/middleware/auth.global.ts @@ -1,5 +1,6 @@ import { useAuthStore } from "#imports"; +const validPaths = ["/login", "/lobby", "/rules", "/test"]; export default defineNuxtRouteMiddleware(async (to, from) => { const authStore = useAuthStore(); const config = useRuntimeConfig(); @@ -37,17 +38,13 @@ export default defineNuxtRouteMiddleware(async (to, from) => { if (to.path.startsWith("/game")) { return; } - if (to.path == "/login") { + if (to.path == "/logout") { + // const session = useCookie("heron.session"); + // session.value = null; + // return navigateTo("/lobby"); return; } - if (to.path == "/lobby") { - return; - } - if (to.path == "/rules") { - return; - } - - if (to.path == "/test") { + if (validPaths.includes(to.path)) { return; } // In a real app you would probably not redirect every route to `/` diff --git a/pages/lobby.vue b/pages/lobby.vue index 4bc78bd..9db3961 100644 --- a/pages/lobby.vue +++ b/pages/lobby.vue @@ -74,10 +74,14 @@ onUnmounted(() => {