From 2e53263cf2d9f7b9a49682626e2e7c71992ab106 Mon Sep 17 00:00:00 2001 From: Vitor Mattos Date: Mon, 2 Dec 2024 12:25:07 -0300 Subject: [PATCH 1/3] fix: block access to route when isn't allowed by admin Now we already don't send data to validation page when the public access to this route is blocked but we follow loading the frontend without data. With this change will redirect to an error page Signed-off-by: Vitor Mattos --- lib/Controller/PageController.php | 1 + src/helpers/SelectAction.js | 3 +++ 2 files changed, 4 insertions(+) diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index 1640ec531d..0188f2301e 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -276,6 +276,7 @@ public function signPdf(string $uuid): TemplateResponse { #[RequireSignRequestUuid] #[FrontpageRoute(verb: 'GET', url: '/p/sign/{uuid}')] public function sign(string $uuid): TemplateResponse { + $this->throwIfValidationPageNotAccessible(); $this->initialState->provideInitialState('action', JSActions::ACTION_SIGN); $this->initialState->provideInitialState('config', $this->accountService->getConfig($this->userSession->getUser()) diff --git a/src/helpers/SelectAction.js b/src/helpers/SelectAction.js index 4f56034bf7..d31808b1cd 100644 --- a/src/helpers/SelectAction.js +++ b/src/helpers/SelectAction.js @@ -55,6 +55,9 @@ export const selectAction = (action, to, from) => { case 5000: // ACTION_INCOMPLETE_SETUP return 'Incomplete' + external default: + if (loadState('libresign', 'error', false)) { + return 'DefaultPageError' + external + } break } } From f39371dfcfc095b2c2755783c2637df2eb8b4ba4 Mon Sep 17 00:00:00 2001 From: Vitor Mattos Date: Mon, 2 Dec 2024 12:28:19 -0300 Subject: [PATCH 2/3] fix: show error message Backend every send as string and not as array Signed-off-by: Vitor Mattos --- src/views/DefaultPageError.vue | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/views/DefaultPageError.vue b/src/views/DefaultPageError.vue index adbf3605ed..3bad5dc0e9 100644 --- a/src/views/DefaultPageError.vue +++ b/src/views/DefaultPageError.vue @@ -25,15 +25,13 @@
-

{{ code || '404' }}

+

404

- {{ message || t('libresign', 'Page not found') }} + {{ t('libresign', 'Page not found') }}

-

{{ paragth }}

- -

- {{ error }} -

+

{{ paragrath }}

+ + {{ error }}
@@ -53,8 +51,8 @@ export default { data() { return { - paragth: t('libresign', 'Sorry but the page you are looking for does not exist, has been removed, moved or is temporarily unavailable.'), - errors: loadState('libresign', 'errors', []), + paragrath: t('libresign', 'Sorry but the page you are looking for does not exist, has been removed, moved or is temporarily unavailable.'), + error: loadState('libresign', 'error', {})?.message, } }, From b5c676dbd453afde5b13dcd7215dfd8b8b665211 Mon Sep 17 00:00:00 2001 From: Vitor Mattos Date: Mon, 2 Dec 2024 12:28:51 -0300 Subject: [PATCH 3/3] fix: prevent infinity loop Signed-off-by: Vitor Mattos --- src/router/router.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/router/router.js b/src/router/router.js index a838c465a9..62237d17c8 100644 --- a/src/router/router.js +++ b/src/router/router.js @@ -205,22 +205,24 @@ const router = new Router({ }) router.beforeEach((to, from, next) => { + const actionElement = document.querySelector('#initial-state-libresign-action') + let action + if (actionElement) { + action = selectAction(loadState('libresign', 'action', ''), to, from) + document.querySelector('#initial-state-libresign-action')?.remove() + } if (Object.hasOwn(to, 'name') && typeof to.name === 'string' && !to.name.endsWith('External') && isExternal(to, from)) { next({ name: to.name + 'External', params: to.params, }) + } else if (action !== undefined) { + next({ + name: action, + params: to.params, + }) } else { - const action = selectAction(loadState('libresign', 'action', ''), to, from) - if (action !== undefined) { - document.querySelector('#initial-state-libresign-action').remove() - next({ - name: action, - params: to.params, - }) - } else { - next() - } + next() } })