Skip to content

Commit 2e05c71

Browse files
authored
Merge pull request #6559 from LibreSign/backport/6557/stable33
[stable33] fix: signature elements without session
2 parents ad9b73b + e91a7e9 commit 2e05c71

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

lib/Service/SignFileService.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -337,12 +337,12 @@ private function bindFileElementWithTempFile(FileElement $fileElement, int $node
337337
}
338338

339339
private function getNode(int $nodeId): ?File {
340-
if ($this->user instanceof IUser) {
340+
try {
341341
return $this->folderService->getFileByNodeId($nodeId);
342+
} catch (\Throwable) {
343+
$filesOfElementes = $this->signerElementsService->getElementsFromSession();
344+
return $this->array_find($filesOfElementes, fn ($file) => $file->getId() === $nodeId);
342345
}
343-
344-
$filesOfElementes = $this->signerElementsService->getElementsFromSession();
345-
return $this->array_find($filesOfElementes, fn ($file) => $file->getId() === $nodeId);
346346
}
347347

348348
/**

tests/php/Unit/Service/SignFileServiceTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,6 +1488,19 @@ public static function providerSetVisibleElements(): array {
14881488
isAuthenticatedSigner: true,
14891489
expectedException: LibresignException::class,
14901490
),
1491+
1492+
'unauthenticated signer with file in folder service (WhatsApp scenario)' => self::createScenarioSetVisibleElements(
1493+
signerList: [
1494+
['documentElementId' => $validDocumentId, 'profileNodeId' => $validProfileNodeId],
1495+
],
1496+
fileElements: [
1497+
['id' => $validDocumentId],
1498+
],
1499+
tempFiles: [$validProfileNodeId => $vfsPath],
1500+
signatureFile: [$validProfileNodeId => ['valid' => true, 'content' => 'valid content']],
1501+
canCreateSignature: true,
1502+
isAuthenticatedSigner: false,
1503+
),
14911504
];
14921505
}
14931506

0 commit comments

Comments
 (0)