diff --git a/src/Http/Handlers/GetHomePage.php b/src/Http/Handlers/GetHomePage.php index 82cd9be..32275ef 100644 --- a/src/Http/Handlers/GetHomePage.php +++ b/src/Http/Handlers/GetHomePage.php @@ -12,30 +12,12 @@ final class GetHomePage /** @param array $params */ public function handle(Request $request, array $params): Response { - $body = <<<'HTML' - - - - - BattleForge - - - - -

BattleForge

-

New scenario

-

Recent scenarios

-

No saved scenarios yet.

- - - -HTML; + $csrf = $request->cookies['__csrf'] ?? ''; - // The CSRF token placeholder is filled by the front controller (Task 16) - // before the body is sent. The handler does not see the cookie or the - // secret; it just receives a pre-issued token from the front controller. - $token = $request->cookies['__csrf'] ?? ''; - $body = str_replace('{{ csrf }}', htmlspecialchars($token, ENT_QUOTES, 'UTF-8'), $body); + ob_start(); + require_once __DIR__ . '/../../Views/layout.php'; + require __DIR__ . '/../../Views/home.php'; + $body = (string) ob_get_clean(); return Response::html(200, $body); }