Browse Source

correctif droits sur API

garthh 3 weeks ago
parent
commit
b41293d529
1 changed files with 4 additions and 1 deletions
  1. 4 1
      src/Controller/Admin/EventConfig/SlotController.php

+ 4 - 1
src/Controller/Admin/EventConfig/SlotController.php

@@ -18,10 +18,13 @@ use App\Service\DateTimeHelper;
 
 final class SlotController extends AbstractController
 {
-    #[IsGranted(new Expression('is_granted("ROLE_ADMIN") or is_granted("ROLE_MANAGER")'))]
     #[Route('/api/slot/{id}/nexts', name: 'api_slot_nexts', requirements: ['id' => '\d+'], methods: ['POST'])]
     public function apiSlotNexts(?Slot $slot, SlotRepository $repository): JsonResponse
     {
+        // Accès uniquement aux gestionnaires ou admin
+        if (!$this->isGranted('ROLE_MANAGER')) {
+            return $this->json(['error' => 'Unauthorized'], 403);
+        }
         if (!$slot) {
             return $this->json(['error' => 'Slot not found'], 404);
         }