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 a88f39e
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 9 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
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ Feature: page/sign_identify_account
And the response should contain the initial state "libresign-pdf" with the following values:
"""
{
"url": "/index.php/apps/libresign/pdf/user/<SIGN_UUID>"
"url": "/index.php/apps/libresign/pdf/<SIGN_UUID>"
}
"""
And the response should contain the initial state "libresign-filename" with the following values:
Expand Down

0 comments on commit a88f39e

Please sign in to comment.