Skip to content

Commit aaad199

Browse files
Fix: change UUID of pdf to be the signer uuid
Signed-off-by: Vitor Mattos <[email protected]>
1 parent bf17da8 commit aaad199

File tree

8 files changed

+14
-9
lines changed

8 files changed

+14
-9
lines changed

appinfo/routes/routesPageController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
['name' => 'page#index', 'url' => '/', 'verb' => 'GET'],
1111
['name' => 'page#indexF', 'url' => '/f/', 'verb' => 'GET'],
1212
['name' => 'page#indexFPath', 'url' => '/f/{path}', 'verb' => 'GET', 'requirements' => ['path' => '.+'], 'postfix' => 'front'],
13-
['name' => 'page#getPdfAccountFile', 'url' => '/pdf/user/{uuid}', 'verb' => 'GET'],
13+
['name' => 'page#getPdfFile', 'url' => '/pdf/{uuid}', 'verb' => 'GET'],
1414
['name' => 'page#resetPassword', 'url' => '/reset-password', 'verb' => 'GET'],
1515
// Pages - public
1616
['name' => 'page#sign', 'url' => '/p/sign/{uuid}', 'verb' => 'GET'],

lib/Controller/AccountController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public function createToSign(string $uuid, string $email, string $password, ?str
108108
'message' => $this->l10n->t('Success'),
109109
'action' => JSActions::ACTION_SIGN,
110110
'pdf' => [
111-
'url' => $this->urlGenerator->linkToRoute('libresign.page.getPdfAccountFile', ['uuid' => $uuid])
111+
'url' => $this->urlGenerator->linkToRoute('libresign.page.getPdfFile', ['uuid' => $uuid])
112112
],
113113
'filename' => $fileToSign['fileData']->getName(),
114114
'description' => $signRequest->getDescription()

lib/Controller/PageController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ public function getPdf($uuid) {
287287
#[PublicPage]
288288
#[RequireSetupOk]
289289
#[AnonRateLimit(limit: 30, period: 60)]
290-
public function getPdfAccountFile($uuid) {
290+
public function getPdfFile($uuid) {
291291
$this->throwIfValidationPageNotAccessible();
292292
$resp = new FileDisplayResponse($this->getNextcloudFile());
293293
$resp->addHeader('Content-Type', 'application/pdf');

lib/Db/AccountFileMapper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function accountFileList(array $filter, int $page = null, int $length = n
9797
$pagination->setCurrentPage($page);
9898
$currentPageResults = $pagination->getCurrentPageResults();
9999

100-
$url = $this->urlGenerator->linkToRoute('libresign.page.getPdfAccountFile', ['uuid' => '_replace_']);
100+
$url = $this->urlGenerator->linkToRoute('libresign.page.getPdfFile', ['uuid' => '_replace_']);
101101
$url = str_replace('_replace_', '', $url);
102102

103103
$data = [];

lib/Db/SignRequestMapper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,7 @@ private function associateAllAndFormat(IUser $user, array $files, array $signers
545545

546546
if ($data['me']) {
547547
$data['sign_uuid'] = $signer->getUuid();
548+
$data['url'] = $this->urlGenerator->linkToRoute('libresign.page.getPdfFile', ['uuid' => $signer->getuuid()]);
548549
}
549550

550551
if ($signer->getSigned()) {
@@ -583,7 +584,6 @@ private function formatListRow(array $row): array {
583584
->setTimestamp((int) $row['request_date'])
584585
->format('Y-m-d H:i:s');
585586
$row['file'] = $this->urlGenerator->linkToRoute('libresign.page.getPdf', ['uuid' => $row['uuid']]);
586-
$row['url'] = $this->urlGenerator->linkToRoute('libresign.page.getPdfAccountFile', ['uuid' => $row['uuid']]);
587587
$row['nodeId'] = (int) $row['node_id'];
588588
$row['uuid'] = $row['uuid'];
589589
unset(

lib/Service/FileService.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ public function setFileByType(string $type, $identifier): self {
177177
}
178178

179179
private function getSigners(): array {
180-
if (!$this->file) {
180+
if ($this->signers) {
181181
return $this->signers;
182182
}
183183
$signers = $this->signRequestMapper->getByFileId($this->file->getId());
@@ -382,7 +382,12 @@ private function getFile(): array {
382382
'displayName' => $this->userManager->get($this->file->getUserId())->getDisplayName(),
383383
];
384384
$return['file'] = $this->urlGenerator->linkToRoute('libresign.page.getPdf', ['uuid' => $this->file->getUuid()]);
385-
$return['url'] = $this->urlGenerator->linkToRoute('libresign.page.getPdfAccountFile', ['uuid' => $this->file->getUuid()]);
385+
foreach ($this->getSigners() as $signer) {
386+
if ($signer['me']) {
387+
$return['url'] = $this->urlGenerator->linkToRoute('libresign.page.getPdfFile', ['uuid' => $signer['sign_uuid']]);
388+
break;
389+
}
390+
}
386391
if ($this->showSigners) {
387392
$return['signers'] = $this->getSigners();
388393
}

lib/Service/SignFileService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ public function getFileUrl(string $format, FileEntity $fileEntity, File $fileToS
683683
$this->accountFileMapper->getByFileId($fileEntity->getId());
684684
$url = ['url' => $this->urlGenerator->linkToRoute('libresign.page.getPdf', ['uuid' => $uuid])];
685685
} catch (DoesNotExistException $e) {
686-
$url = ['url' => $this->urlGenerator->linkToRoute('libresign.page.getPdfAccountFile', ['uuid' => $uuid])];
686+
$url = ['url' => $this->urlGenerator->linkToRoute('libresign.page.getPdfFile', ['uuid' => $uuid])];
687687
}
688688
break;
689689
case 'nodeId':

tests/integration/features/page/sign_identify_account.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ Feature: page/sign_identify_account
9595
And the response should contain the initial state "libresign-pdf" with the following values:
9696
"""
9797
{
98-
"url": "/index.php/apps/libresign/pdf/user/<SIGN_UUID>"
98+
"url": "/index.php/apps/libresign/pdf/<SIGN_UUID>"
9999
}
100100
"""
101101
And the response should contain the initial state "libresign-filename" with the following values:

0 commit comments

Comments
 (0)