The session will have the form key, no need to inject it into the template.

This commit is contained in:
Dave Smith-Hayes 2025-04-15 21:39:21 -04:00
parent 8a936fc2f7
commit 4477962d3a
4 changed files with 1 additions and 15 deletions

View File

@ -8,13 +8,8 @@ use Slovocast\Handler\Handler;
class CreateChannelPage extends Handler class CreateChannelPage extends Handler
{ {
public function __construct(
private SessionInterface $session
) { }
public function handle(): Response public function handle(): Response
{ {
$formKey = $this->session->get("form_key");
return $this->render('channel/create.twig', [ 'form_key' => $formKey ]); return $this->render('channel/create.twig', [ 'form_key' => $formKey ]);
} }
} }

View File

@ -8,13 +8,8 @@ use Slovocast\Handler\Handler;
class LoginUserPage extends Handler class LoginUserPage extends Handler
{ {
public function __construct(
private SessionInterface $session
) { }
public function handle(): Response public function handle(): Response
{ {
$formKey = $this->session->get("form_key");
return $this->render('user/login.twig'); return $this->render('user/login.twig');
} }
} }

View File

@ -8,13 +8,8 @@ use Slovocast\Handler\Handler;
class RegisterUserPage extends Handler class RegisterUserPage extends Handler
{ {
public function __construct(
private SessionInterface $session
) { }
public function handle(): Response public function handle(): Response
{ {
$formKey = $this->session->get("form_key");
return $this->render('user/register.twig', [ 'form_key' => $formKey ]); return $this->render('user/register.twig', [ 'form_key' => $formKey ]);
} }
} }

View File

@ -3,6 +3,7 @@
{% block content %} {% block content %}
<div> <div>
<form action="/login" method="post"> <form action="/login" method="post">
<input name="form_key" type="hidden" value="{{ session.get('form_key') }}"
<div> <div>
<label for="email">Email<br> <label for="email">Email<br>
<input name="email" type="text" required> <input name="email" type="text" required>