From 16350554c72f643c8294b55813b963fa2ba6299c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C5=A0pa=C4=8Dek?= Date: Fri, 26 Jul 2024 02:45:09 +0200 Subject: [PATCH] The Forbidden presenter can echo more messages --- site/app/Www/Presenters/BasePresenter.php | 2 +- site/app/Www/Presenters/ForbiddenPresenter.php | 3 ++- site/app/Www/Presenters/templates/Forbidden/default.latte | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/site/app/Www/Presenters/BasePresenter.php b/site/app/Www/Presenters/BasePresenter.php index ab857b717..c2e525ae1 100644 --- a/site/app/Www/Presenters/BasePresenter.php +++ b/site/app/Www/Presenters/BasePresenter.php @@ -85,7 +85,7 @@ protected function startup(): void parent::startup(); $this->httpResponse->addHeader('Vary', 'Cookie'); if ($this->authenticator->isForbidden() && $this->getRequest()?->getMethod() !== Request::FORWARD) { - $this->forward(':Www:Forbidden:'); + $this->forward(':Www:Forbidden:', ['message' => 'messages.forbidden.spam']); } } diff --git a/site/app/Www/Presenters/ForbiddenPresenter.php b/site/app/Www/Presenters/ForbiddenPresenter.php index e53fb3213..62abaefc8 100644 --- a/site/app/Www/Presenters/ForbiddenPresenter.php +++ b/site/app/Www/Presenters/ForbiddenPresenter.php @@ -34,10 +34,11 @@ protected function startup(): void } - public function actionDefault(): void + public function actionDefault(string $message): void { $this->httpResponse->setCode(IResponse::S403_Forbidden); $this->template->pageTitle = $this->translator->translate('messages.title.forbidden'); + $this->template->message = $this->translator->translate($message); } } diff --git a/site/app/Www/Presenters/templates/Forbidden/default.latte b/site/app/Www/Presenters/templates/Forbidden/default.latte index 668722f04..4974fbaed 100644 --- a/site/app/Www/Presenters/templates/Forbidden/default.latte +++ b/site/app/Www/Presenters/templates/Forbidden/default.latte @@ -1,3 +1,3 @@ {define #content} -

{_messages.forbidden.spam}

+

{$message}

{/define}