Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable30] fix: block access to route when isn't allowed by admin #4096

Merged
merged 3 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/Controller/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
3 changes: 3 additions & 0 deletions src/helpers/SelectAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
22 changes: 12 additions & 10 deletions src/router/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
})

Expand Down
16 changes: 7 additions & 9 deletions src/views/DefaultPageError.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,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 @@ -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,
}
},

Expand Down
Loading