Skip to content

Commit

Permalink
Fix: change UUID of pdf to be the signer uuid
Browse files Browse the repository at this point in the history
Signed-off-by: Vitor Mattos <[email protected]>
  • Loading branch information
vitormattos committed Apr 1, 2024
1 parent 11e35ff commit f3ccf02
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion appinfo/routes/routesPageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
['name' => 'page#index', 'url' => '/', 'verb' => 'GET'],
['name' => 'page#indexF', 'url' => '/f/', 'verb' => 'GET'],
['name' => 'page#indexFPath', 'url' => '/f/{path}', 'verb' => 'GET', 'requirements' => ['path' => '.+'], 'postfix' => 'front'],
['name' => 'page#getPdfAccountFile', 'url' => '/pdf/user/{uuid}', 'verb' => 'GET'],
['name' => 'page#getPdfFile', 'url' => '/pdf/{uuid}', 'verb' => 'GET'],
['name' => 'page#resetPassword', 'url' => '/reset-password', 'verb' => 'GET'],
// Pages - public
['name' => 'page#sign', 'url' => '/p/sign/{uuid}', 'verb' => 'GET'],
Expand Down
2 changes: 1 addition & 1 deletion lib/Controller/AccountController.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function createToSign(string $uuid, string $email, string $password, ?str
'message' => $this->l10n->t('Success'),
'action' => JSActions::ACTION_SIGN,
'pdf' => [
'url' => $this->urlGenerator->linkToRoute('libresign.page.getPdfAccountFile', ['uuid' => $uuid])
'url' => $this->urlGenerator->linkToRoute('libresign.page.getPdfFile', ['uuid' => $uuid])
],
'filename' => $fileToSign['fileData']->getName(),
'description' => $signRequest->getDescription()
Expand Down
2 changes: 1 addition & 1 deletion lib/Controller/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ public function getPdf($uuid) {
#[PublicPage]
#[RequireSetupOk]
#[AnonRateLimit(limit: 30, period: 60)]
public function getPdfAccountFile($uuid) {
public function getPdfFile($uuid) {
$this->throwIfValidationPageNotAccessible();
$resp = new FileDisplayResponse($this->getNextcloudFile());
$resp->addHeader('Content-Type', 'application/pdf');
Expand Down
2 changes: 1 addition & 1 deletion lib/Db/AccountFileMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function accountFileList(array $filter, int $page = null, int $length = n
$pagination->setCurrentPage($page);
$currentPageResults = $pagination->getCurrentPageResults();

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

$data = [];
Expand Down
2 changes: 1 addition & 1 deletion lib/Db/SignRequestMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ private function associateAllAndFormat(IUser $user, array $files, array $signers

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

if ($signer->getSigned()) {
Expand Down Expand Up @@ -583,7 +584,6 @@ private function formatListRow(array $row): array {
->setTimestamp((int) $row['request_date'])
->format('Y-m-d H:i:s');
$row['file'] = $this->urlGenerator->linkToRoute('libresign.page.getPdf', ['uuid' => $row['uuid']]);
$row['url'] = $this->urlGenerator->linkToRoute('libresign.page.getPdfAccountFile', ['uuid' => $row['uuid']]);
$row['nodeId'] = (int) $row['node_id'];
$row['uuid'] = $row['uuid'];
unset(
Expand Down
9 changes: 7 additions & 2 deletions lib/Service/FileService.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public function setFileByType(string $type, $identifier): self {
}

private function getSigners(): array {
if (!$this->file) {
if ($this->signers) {
return $this->signers;
}
$signers = $this->signRequestMapper->getByFileId($this->file->getId());
Expand Down Expand Up @@ -382,7 +382,12 @@ private function getFile(): array {
'displayName' => $this->userManager->get($this->file->getUserId())->getDisplayName(),
];
$return['file'] = $this->urlGenerator->linkToRoute('libresign.page.getPdf', ['uuid' => $this->file->getUuid()]);
$return['url'] = $this->urlGenerator->linkToRoute('libresign.page.getPdfAccountFile', ['uuid' => $this->file->getUuid()]);
foreach ($this->getSigners() as $signer) {
if ($signer['me']) {
$return['url'] = $this->urlGenerator->linkToRoute('libresign.page.getPdfFile', ['uuid' => $signer['sign_uuid']]);
break;
}
}
if ($this->showSigners) {
$return['signers'] = $this->getSigners();
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Service/SignFileService.php
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ public function getFileUrl(string $format, FileEntity $fileEntity, File $fileToS
$this->accountFileMapper->getByFileId($fileEntity->getId());
$url = ['url' => $this->urlGenerator->linkToRoute('libresign.page.getPdf', ['uuid' => $uuid])];
} catch (DoesNotExistException $e) {
$url = ['url' => $this->urlGenerator->linkToRoute('libresign.page.getPdfAccountFile', ['uuid' => $uuid])];
$url = ['url' => $this->urlGenerator->linkToRoute('libresign.page.getPdfFile', ['uuid' => $uuid])];
}
break;
case 'nodeId':
Expand Down

0 comments on commit f3ccf02

Please sign in to comment.