From f8a986d59bdc147f3c2301cd0a126d00cc88f1af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 12 Sep 2024 11:18:15 +0200 Subject: [PATCH] Add user IP and authenticated user details to signature Updated the SignatureRequest metadata to include the requester's IP address and currently authenticated user details. Also improved the rendering of signer information by leveraging the `ChillEntityRenderManagerInterface`. --- .../Controller/SignatureRequestController.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillDocStoreBundle/Controller/SignatureRequestController.php b/src/Bundle/ChillDocStoreBundle/Controller/SignatureRequestController.php index 70d126f78..606bafb15 100644 --- a/src/Bundle/ChillDocStoreBundle/Controller/SignatureRequestController.php +++ b/src/Bundle/ChillDocStoreBundle/Controller/SignatureRequestController.php @@ -16,11 +16,13 @@ use Chill\DocStoreBundle\Service\Signature\PDFPage; use Chill\DocStoreBundle\Service\Signature\PDFSignatureZone; use Chill\DocStoreBundle\Service\StoredObjectManagerInterface; use Chill\MainBundle\Entity\Workflow\EntityWorkflowStepSignature; +use Chill\MainBundle\Templating\Entity\ChillEntityRenderManagerInterface; use Chill\MainBundle\Workflow\EntityWorkflowManager; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Messenger\MessageBusInterface; use Symfony\Component\Routing\Annotation\Route; +use Symfony\Component\Security\Core\Security; class SignatureRequestController { @@ -28,6 +30,8 @@ class SignatureRequestController private readonly MessageBusInterface $messageBus, private readonly StoredObjectManagerInterface $storedObjectManager, private readonly EntityWorkflowManager $entityWorkflowManager, + private readonly ChillEntityRenderManagerInterface $entityRender, + private readonly Security $security, ) {} #[Route('/api/1.0/document/workflow/{id}/signature-request', name: 'chill_docstore_signature_request')] @@ -51,8 +55,14 @@ class SignatureRequestController $signature->getId(), $zone, $data['zone']['index'], - 'test signature', // reason (string) - 'Mme Caroline Diallo', // signerText (string) + 'Signed by IP: '.(string) $request->getClientIp().', authenticated user: '.$this->entityRender->renderString($this->security->getUser(), []), + $this->entityRender->renderString($signature->getSigner(), [ + // options for user render + 'absence' => false, + 'main_scope' => false, + // options for person render + 'addAge' => false, + ]), $content ));