import { useAuthStore } from '~/stores/auth' export default defineNuxtRouteMiddleware(async (to) => { const auth = useAuthStore() const guestAllowedPaths = [ '/', '/reception/waiting-reception', '/reception/finish-reception', '/shipment/waiting-shipment', '/shipment/finish-shipment' ] if (to.path === '/login') { return } if (!auth.isAuthenticated) { await auth.ensureSession() } if (!auth.isAuthenticated) { return navigateTo('/login') } if (auth.isGuest && !guestAllowedPaths.includes(to.path)) { return navigateTo('/') } })