perf(router): añadido acceso a Gestión solo para Admin

parent 13c51ea9
Showing with 4 additions and 4 deletions
......@@ -58,7 +58,7 @@ const routes = [
path: '/users/management',
name: 'UserManagement',
component: UserManagement,
meta: { requiresAuth: true }
meta: { requiresAuth: true, requiresAdmin: true }
}
]
......@@ -70,15 +70,15 @@ const router = createRouter({
router.beforeEach((to, from, next) => {
const authStore = useAuthStore();
const requiresAuth = to.matched.some(record => record.meta.requiresAuth);
const requiresAdmin = to.matched.some(record => record.meta.requiresAdmin);
// Si el usuario no está autenticado
if (requiresAuth && !authStore.isAuthenticated) {
next({ path: '/auth/login' });
} else if (requiresAdmin && authStore.user?.role != 'Admin') {
next({ path: '/recipes' });
} else {
next();
}
// Si el usuario no es ADMIN ...
})
export default router
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment