diff --git a/src/Bundle/ChillDocStoreBundle/Controller/SignatureRequestController.php b/src/Bundle/ChillDocStoreBundle/Controller/SignatureRequestController.php index 26fc1b098..c6c564be1 100644 --- a/src/Bundle/ChillDocStoreBundle/Controller/SignatureRequestController.php +++ b/src/Bundle/ChillDocStoreBundle/Controller/SignatureRequestController.php @@ -18,10 +18,12 @@ use Chill\DocStoreBundle\Service\StoredObjectManagerInterface; use Chill\MainBundle\Entity\Workflow\EntityWorkflowSignatureStateEnum; use Chill\MainBundle\Entity\Workflow\EntityWorkflowStepSignature; use Chill\MainBundle\Templating\Entity\ChillEntityRenderManagerInterface; +use Chill\MainBundle\Security\Authorization\EntityWorkflowStepSignatureVoter; use Chill\MainBundle\Workflow\EntityWorkflowManager; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\Messenger\MessageBusInterface; use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Security\Core\Security; @@ -41,6 +43,10 @@ class SignatureRequestController #[Route('/api/1.0/document/workflow/{id}/signature-request', name: 'chill_docstore_signature_request')] public function processSignature(EntityWorkflowStepSignature $signature, Request $request): JsonResponse { + if (!$this->security->isGranted(EntityWorkflowStepSignatureVoter::SIGN, $signature)) { + throw new AccessDeniedHttpException('not authorized to sign this step'); + } + $entityWorkflow = $signature->getStep()->getEntityWorkflow(); if (EntityWorkflowSignatureStateEnum::PENDING !== $signature->getState()) { diff --git a/src/Bundle/ChillMainBundle/Controller/WorkflowAddSignatureController.php b/src/Bundle/ChillMainBundle/Controller/WorkflowAddSignatureController.php index deb90119b..2aa180b7a 100644 --- a/src/Bundle/ChillMainBundle/Controller/WorkflowAddSignatureController.php +++ b/src/Bundle/ChillMainBundle/Controller/WorkflowAddSignatureController.php @@ -14,13 +14,16 @@ namespace Chill\MainBundle\Controller; use Chill\DocStoreBundle\Service\Signature\PDFSignatureZoneAvailable; use Chill\MainBundle\Entity\Workflow\EntityWorkflowSignatureStateEnum; use Chill\MainBundle\Entity\Workflow\EntityWorkflowStepSignature; +use Chill\MainBundle\Security\Authorization\EntityWorkflowStepSignatureVoter; use Chill\MainBundle\Workflow\EntityWorkflowManager; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; +use Symfony\Component\Security\Core\Security; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; use Twig\Environment; @@ -32,11 +35,16 @@ final readonly class WorkflowAddSignatureController private NormalizerInterface $normalizer, private Environment $twig, private UrlGeneratorInterface $urlGenerator, + private Security $security, ) {} #[Route(path: '/{_locale}/main/workflow/signature/{id}/sign', name: 'chill_main_workflow_signature_add', methods: 'GET')] public function __invoke(EntityWorkflowStepSignature $signature, Request $request): Response { + if (!$this->security->isGranted(EntityWorkflowStepSignatureVoter::SIGN, $signature)) { + throw new AccessDeniedHttpException('not authorized to sign this step'); + } + $entityWorkflow = $signature->getStep()->getEntityWorkflow(); if (EntityWorkflowSignatureStateEnum::PENDING !== $signature->getState()) { diff --git a/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflow.php b/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflow.php index 08b5ee41f..89efde7c0 100644 --- a/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflow.php +++ b/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflow.php @@ -318,7 +318,7 @@ class EntityWorkflow implements TrackCreationInterface, TrackUpdateInterface } } - return $usersInvolved; + return array_values($usersInvolved); } public function getWorkflowName(): string @@ -446,6 +446,10 @@ class EntityWorkflow implements TrackCreationInterface, TrackUpdateInterface $newStep->addDestUser($user); } + if (null !== $transitionContextDTO->futureUserSignature) { + $newStep->addDestUser($transitionContextDTO->futureUserSignature); + } + foreach ($transitionContextDTO->futureDestEmails as $email) { $newStep->addDestEmail($email); } diff --git a/src/Bundle/ChillMainBundle/Resources/views/Workflow/_signature.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Workflow/_signature.html.twig index 50172089c..b0e401645 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Workflow/_signature.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Workflow/_signature.html.twig @@ -23,14 +23,18 @@ {% if s.isSigned %} {{ 'workflow.signature_zone.has_signed_statement'|trans({ 'datetime' : s.stateDate }) }} {% else %} -
{{ s.stateDate }}
- {% endif %} -{{ s.stateDate }}
+ {% endif %} +