mirror of
https://github.com/rustfs/console.git
synced 2026-09-19 09:52:25 +08:00
20 lines
365 B
TypeScript
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')
|
|
}
|
|
})
|