Files
Inventory/app/middleware/profile.global.ts
2025-09-18 08:30:29 +02:00

15 lines
467 B
TypeScript

import { useProfileSession } from '#imports'
export default defineNuxtRouteMiddleware(async (to) => {
const { ensureSession, activeProfile } = useProfileSession()
await ensureSession()
const path = to.path || ''
const routeName = typeof to.name === 'string' ? to.name : ''
const isProfilesRoute = path.startsWith('/profiles') || routeName.startsWith('profiles')
if (!activeProfile.value && !isProfilesRoute) {
return navigateTo('/profiles')
}
})