Skip to content

Commit

Permalink
Merge pull request #4095 from LibreSign/backport/4094/stable29
Browse files Browse the repository at this point in the history
[stable29] fix: block access to route when isn't allowed by admin
  • Loading branch information
vitormattos authored Dec 2, 2024
2 parents 86c6b62 + b5c676d commit c0a2095
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 19 deletions.
1 change: 1 addition & 0 deletions lib/Controller/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
3 changes: 3 additions & 0 deletions src/helpers/SelectAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
22 changes: 12 additions & 10 deletions src/router/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
})

Expand Down
16 changes: 7 additions & 9 deletions src/views/DefaultPageError.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,13 @@
<div class="container">
<div id="img" />
<div class="content">
<h1>{{ code || '404' }}</h1>
<h1>404</h1>
<h2>
{{ message || t('libresign', 'Page not found') }}
{{ t('libresign', 'Page not found') }}
</h2>
<p>{{ paragth }}</p>
<NcNoteCard v-if="errors.length > 0" type="error" heading="Error">
<p v-for="error in errors" :key="error">
{{ error }}
</p>
<p>{{ paragrath }}</p>
<NcNoteCard v-if="error" type="error" heading="Error">
{{ error }}
</NcNoteCard>
</div>
</div>
Expand All @@ -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,
}
},

Expand Down

0 comments on commit c0a2095

Please sign in to comment.