ffplayout/frontend/middleware/auth.global.ts

11 lines
273 B
TypeScript
Raw Normal View History

2024-04-16 12:13:28 -04:00
export default defineNuxtRouteMiddleware((to) => {
2023-01-11 04:54:25 -05:00
const auth = useAuth()
2024-04-11 15:34:03 -04:00
const localePath = useLocalePath()
2023-01-11 04:54:25 -05:00
auth.inspectToken()
2024-04-11 15:34:03 -04:00
if (!auth.isLogin && !String(to.name).includes('index_')) {
return navigateTo(localePath({ name: 'index' }))
2023-01-11 04:54:25 -05:00
}
})