All checks were successful
Auto Tag Develop / tag (push) Successful in 6s
Reviewed-on: #1 Co-authored-by: tristan <tristan@yuno.malio.fr> Co-committed-by: tristan <tristan@yuno.malio.fr>
17 lines
399 B
TypeScript
17 lines
399 B
TypeScript
export default defineNuxtRouteMiddleware(async (to) => {
|
|
const auth = useAuthStore()
|
|
const isLogin = to.path === '/login'
|
|
|
|
if (!auth.checked) {
|
|
await auth.ensureSession()
|
|
}
|
|
|
|
if (!isLogin && !auth.isAuthenticated) {
|
|
return navigateTo('/login')
|
|
}
|
|
|
|
if (auth.isAuthenticated && (isLogin || to.path === '/')) {
|
|
return navigateTo('/dashboard')
|
|
}
|
|
})
|