#44 feat: restringir acceso a compras para usuarios con rol publico
This commit is contained in:
@@ -11,6 +11,8 @@ import { setupLayouts } from 'virtual:generated-layouts'
|
||||
import { routes } from 'vue-router/auto-routes'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
|
||||
const PUBLICO_RESTRICTED = ['/comprar']
|
||||
|
||||
const ADMIN_ROUTES = [
|
||||
'/sincronizar_clientes_tryton',
|
||||
'/sincronizar_ventas_tryton',
|
||||
@@ -40,6 +42,8 @@ router.beforeEach((to, from, next) => {
|
||||
next({ path: '/autenticarse', replace: true })
|
||||
} else if (requiresAdmin && !authStore.isAdmin && authStore.user) {
|
||||
next({ path: '/', replace: true })
|
||||
} else if (authStore.user?.role === 'publico' && PUBLICO_RESTRICTED.includes(to.path)) {
|
||||
next({ path: '/catalog', replace: true })
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user