15 lines
467 B
TypeScript
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')
|
|
}
|
|
})
|