Skip to content
This repository has been archived by the owner on Jul 26, 2024. It is now read-only.

Commit

Permalink
Allows the store keeper to access to store route
Browse files Browse the repository at this point in the history
  • Loading branch information
Fred-57 committed Jul 25, 2024
1 parent 7571da1 commit 7aa6337
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions frontend/src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,22 +319,25 @@ const adminRoutes = [
'admin_orders',
'admin_orders_edit',
'admin_variants',
'admin_variants_add',
'admin_variants_edit'
'admin_variants_add'
]

const storeRoutes = ['admin_store', 'admin_dashboard', 'admin_variants_edit', 'store']

router.beforeEach(async (to) => {
const { isAuthenticated, roles } = await checkAuth()

// Si l'utilisateur n'est pas authentifié et qu'il tente d'accéder à une route protégée (non publique)
if (!publicRoutes.includes(to.name as string) && !isAuthenticated) {
router.push('/')
}

// Ne pas autoriser les utilisateurs non-admin à accéder aux routes d'admin
if (!roles.includes('ADMIN') && adminRoutes.includes(to.name as string)) {
router.push('/')
}

// Ne pas autoriser les utilisateurs non-admin et non-store_keeper à accéder aux routes de store et admin
if (
!roles.includes('ADMIN') &&
!roles.includes('STORE_KEEPER') &&
Expand Down

0 comments on commit 7aa6337

Please sign in to comment.