You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
export default defineNuxtRouteMiddleware(async (to, from) => {
|
|
const user = useUser()
|
|
await getUser()
|
|
|
|
if (!user.value && to.path !== '/login' && to.path.startsWith('/')) {
|
|
return navigateTo('/login')
|
|
}
|
|
|
|
if (user.value && to.path === '/login') {
|
|
return navigateTo('/')
|
|
}
|
|
})
|