Files
rustfs-console/middleware/auth.global.ts
T
2025-01-11 15:25:46 +08:00

20 lines
365 B
TypeScript

export default defineNuxtRouteMiddleware((to, from) => {
const isAuthenticated = useAuth().isAuthenticated.value
console.debug('Auth middleware', to.path, isAuthenticated);
if (to.path === '/auth/login') {
if (isAuthenticated) {
return navigateTo('/')
}
return
}
if (!isAuthenticated) {
return navigateTo('/auth/login')
}
})