@@ -2,6 +2,13 @@ import { useAuthStore } from '~/stores/auth'
|
||||
|
||||
export default defineNuxtRouteMiddleware(async (to) => {
|
||||
const auth = useAuthStore()
|
||||
const guestAllowedPaths = [
|
||||
'/',
|
||||
'/reception/waiting-reception',
|
||||
'/reception/finish-reception',
|
||||
'/shipment/waiting-shipment',
|
||||
'/shipment/finish-shipment'
|
||||
]
|
||||
|
||||
if (to.path === '/login') {
|
||||
return
|
||||
@@ -14,4 +21,8 @@ export default defineNuxtRouteMiddleware(async (to) => {
|
||||
if (!auth.isAuthenticated) {
|
||||
return navigateTo('/login')
|
||||
}
|
||||
|
||||
if (auth.isGuest && !guestAllowedPaths.includes(to.path)) {
|
||||
return navigateTo('/')
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user