From 038ed65668e4ea0520838d5346101f934413782b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=91cze=20Bence?= Date: Sun, 16 Apr 2023 17:50:43 +0200 Subject: [PATCH] fixup! split authentication required and secured controllers --- public/index.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/public/index.php b/public/index.php index a421e6f..81dfb54 100644 --- a/public/index.php +++ b/public/index.php @@ -1,7 +1,12 @@ isAuthenticationRequired() && Container::$request->user() === null ) { @@ -34,28 +39,28 @@ if ($match !== null) { } if ($method === 'post' && !in_array($url, $antiCsrfTokenExceptions) && Container::$request->post('anti_csrf_token') !== Container::$request->session()->get('anti_csrf_token')) { - $content = new SokoWeb\Response\JsonContent(['error' => 'no_valid_anti_csrf_token']); + $content = new JsonContent(['error' => 'no_valid_anti_csrf_token']); header('Content-Type: text/html; charset=UTF-8', true, 403); $content->render(); return; } if ( - !($controller instanceof SokoWeb\Interfaces\Authorization\ISecured) || + !($controller instanceof ISecured) || $controller->authorize() ) { $response = call_user_func([$controller, $handler[1]]); - if ($response instanceof SokoWeb\Interfaces\Response\IContent) { + if ($response instanceof IContent) { header('Content-Type: ' . $response->getContentType() . '; charset=UTF-8'); $response->render(); return; - } elseif ($response instanceof SokoWeb\Interfaces\Response\IRedirect) { + } elseif ($response instanceof IRedirect) { header('Location: ' . $response->getUrl(), true, $response->getHttpCode()); return; } } } -$content = new SokoWeb\Response\HtmlContent('error/404'); +$content = new HtmlContent('error/404'); header('Content-Type: text/html; charset=UTF-8', true, 404); $content->render();