From f757083d9011307d7486633624515fa0fab139e0 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 5bddef84e7..c10d278383 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -260,6 +260,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 034166f6db..ab31248d8d 100644 --- a/src/helpers/SelectAction.js +++ b/src/helpers/SelectAction.js @@ -37,6 +37,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 5584800e63349c0314263af961e54fd1fa315d77 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 68e746b5f3..1ab5ede7e2 100644 --- a/src/views/DefaultPageError.vue +++ b/src/views/DefaultPageError.vue @@ -7,15 +7,13 @@
-

{{ code || '404' }}

+

404

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

-

{{ paragth }}

- -

- {{ error }} -

+

{{ paragrath }}

+ + {{ error }}
@@ -35,8 +33,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 59f6c97eaf2c04703487f52d53334b8649681dff 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 ca66b65f8c..ef852a84bc 100644 --- a/src/router/router.js +++ b/src/router/router.js @@ -188,22 +188,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() } })