2026-10-30 10:17:34 +00:00
|
|
|
/** Pages for visitors: the landing page and the account forms send players on to their worlds. */
|
|
|
|
|
const GUEST_PATHS = ['/', '/login', '/register']
|
|
|
|
|
/** Pages anyone may read. */
|
|
|
|
|
const OPEN_PATHS = ['/imprint', '/privacy', '/terms']
|
2026-10-28 16:57:43 +00:00
|
|
|
|
|
|
|
|
export default defineNuxtRouteMiddleware((to) => {
|
|
|
|
|
const loggedIn = gameAuth.token() !== null
|
2026-10-30 10:17:34 +00:00
|
|
|
if (OPEN_PATHS.includes(to.path)) return
|
|
|
|
|
const isGuest = GUEST_PATHS.includes(to.path)
|
|
|
|
|
if (!loggedIn && !isGuest) return navigateTo('/login')
|
|
|
|
|
if (loggedIn && isGuest) return navigateTo('/worlds')
|
2026-10-28 16:57:43 +00:00
|
|
|
})
|