Skip to content

Commit

Permalink
fix: redirect url
Browse files Browse the repository at this point in the history
Signed-off-by: Vitor Mattos <[email protected]>
  • Loading branch information
vitormattos authored and backportbot-libresign[bot] committed Jan 28, 2025
1 parent 039e4c1 commit 20465b5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
16 changes: 12 additions & 4 deletions lib/Controller/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -605,14 +605,22 @@ private function throwIfValidationPageNotAccessible(): void {
return;
}
if ($isValidationUrlPrivate) {
if ($uuid = $this->request->getParam('uuid')) {
$redirectUrl = $this->urlGenerator->linkToRoute(
'libresign.page.validationFilePublic',
['uuid' => $uuid]
);
} else {
$redirectUrl = $this->urlGenerator->linkToRoute(
'libresign.page.validation',
);
}

throw new LibresignException(json_encode([
'action' => JSActions::ACTION_REDIRECT,
'errors' => [$this->l10n->t('You are not logged in. Please log in.')],
'redirect' => $this->urlGenerator->linkToRoute('core.login.showLoginForm', [
'redirect_url' => $this->urlGenerator->linkToRoute(
'libresign.page.validationFilePublic',
['uuid' => $this->request->getParam('uuid')]
),
'redirect_url' => $redirectUrl,
]),
]), Http::STATUS_UNAUTHORIZED);
}
Expand Down
7 changes: 5 additions & 2 deletions tests/integration/features/page/validate.feature
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Feature: page/validate
Background: Make setup ok
Given run the command "config:app:set libresign authkey --value=dummy" with result code 0
And run the command "libresign:configure:openssl --cn test" with result code 0

Scenario: Unauthenticated user can see sign page
Given as user "admin"
Expand All @@ -16,5 +17,7 @@ Feature: page/validate
And as user ""
When sending "get" to "/apps/libresign/p/validation"
And the response should be a JSON array with the following mandatory values
| key | value |
| message | Current user is not logged in |
| key | value |
| errors | ["You are not logged in. Please log in."] |
| action | 1000 |
| redirect | /index.php/login?redirect_url=/index.php/apps/libresign/p/validation |

0 comments on commit 20465b5

Please sign in to comment.