diff --git a/src/Bundle/ChillMainBundle/Security/Authorization/ExportGenerationVoter.php b/src/Bundle/ChillMainBundle/Security/Authorization/ExportGenerationVoter.php new file mode 100644 index 000000000..008f76b40 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Security/Authorization/ExportGenerationVoter.php @@ -0,0 +1,32 @@ +getUser()->getUserIdentifier() === $subject->getCreatedBy()->getUserIdentifier(); + } +} diff --git a/src/Bundle/ChillMainBundle/Security/Authorization/StoredObject/ExportGenerationStoredObjectVoter.php b/src/Bundle/ChillMainBundle/Security/Authorization/StoredObject/ExportGenerationStoredObjectVoter.php index 5dd1ecac8..4979ffec2 100644 --- a/src/Bundle/ChillMainBundle/Security/Authorization/StoredObject/ExportGenerationStoredObjectVoter.php +++ b/src/Bundle/ChillMainBundle/Security/Authorization/StoredObject/ExportGenerationStoredObjectVoter.php @@ -15,11 +15,13 @@ use Chill\DocStoreBundle\Entity\StoredObject; use Chill\DocStoreBundle\Security\Authorization\StoredObjectRoleEnum; use Chill\DocStoreBundle\Security\Authorization\StoredObjectVoterInterface; use Chill\MainBundle\Repository\ExportGenerationRepository; +use Chill\MainBundle\Security\Authorization\ExportGenerationVoter; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; +use Symfony\Component\Security\Core\Security; final readonly class ExportGenerationStoredObjectVoter implements StoredObjectVoterInterface { - public function __construct(private ExportGenerationRepository $repository) {} + public function __construct(private ExportGenerationRepository $repository, private Security $security) {} public function supports(StoredObjectRoleEnum $attribute, StoredObject $subject): bool { @@ -36,6 +38,6 @@ final readonly class ExportGenerationStoredObjectVoter implements StoredObjectVo throw new \UnexpectedValueException('generation not found'); } - return $token->getUser()->getUserIdentifier() === $generation->getCreatedBy()->getUserIdentifier(); + return $this->security->isGranted(ExportGenerationVoter::VIEW, $generation); } }