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`.
This commit is contained in:
Julien Fastré 2024-09-12 11:18:15 +02:00
parent 09563979a2
commit f8a986d59b
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB

View File

@ -16,11 +16,13 @@ use Chill\DocStoreBundle\Service\Signature\PDFPage;
use Chill\DocStoreBundle\Service\Signature\PDFSignatureZone; use Chill\DocStoreBundle\Service\Signature\PDFSignatureZone;
use Chill\DocStoreBundle\Service\StoredObjectManagerInterface; use Chill\DocStoreBundle\Service\StoredObjectManagerInterface;
use Chill\MainBundle\Entity\Workflow\EntityWorkflowStepSignature; use Chill\MainBundle\Entity\Workflow\EntityWorkflowStepSignature;
use Chill\MainBundle\Templating\Entity\ChillEntityRenderManagerInterface;
use Chill\MainBundle\Workflow\EntityWorkflowManager; use Chill\MainBundle\Workflow\EntityWorkflowManager;
use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Messenger\MessageBusInterface; use Symfony\Component\Messenger\MessageBusInterface;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Security;
class SignatureRequestController class SignatureRequestController
{ {
@ -28,6 +30,8 @@ class SignatureRequestController
private readonly MessageBusInterface $messageBus, private readonly MessageBusInterface $messageBus,
private readonly StoredObjectManagerInterface $storedObjectManager, private readonly StoredObjectManagerInterface $storedObjectManager,
private readonly EntityWorkflowManager $entityWorkflowManager, 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')] #[Route('/api/1.0/document/workflow/{id}/signature-request', name: 'chill_docstore_signature_request')]
@ -51,8 +55,14 @@ class SignatureRequestController
$signature->getId(), $signature->getId(),
$zone, $zone,
$data['zone']['index'], $data['zone']['index'],
'test signature', // reason (string) 'Signed by IP: '.(string) $request->getClientIp().', authenticated user: '.$this->entityRender->renderString($this->security->getUser(), []),
'Mme Caroline Diallo', // signerText (string) $this->entityRender->renderString($signature->getSigner(), [
// options for user render
'absence' => false,
'main_scope' => false,
// options for person render
'addAge' => false,
]),
$content $content
)); ));