Still can't find out why the flash isn't setting and rendering to the page.

This commit is contained in:
Dave Smith-Hayes 2024-11-24 22:19:07 -05:00
parent f6fc19a55f
commit 5f2e7476ff
2 changed files with 19 additions and 3 deletions

View File

@ -27,13 +27,19 @@ class LoginUserAction extends Controller
$user = $this->userRepository->getFromEmail($credentials['email']); $user = $this->userRepository->getFromEmail($credentials['email']);
} catch (EntityNotFoundException $e) { } catch (EntityNotFoundException $e) {
$this->logger->error("Unable to login user."); $this->logger->error("Unable to login user.");
$this->session->getFlash()->add('error', "Unable to login user."); $this->session
->getFlash()
->add('error', "Unable to login user.");
return $this->render('user/login.twig')->withStatus(400); return $this->render('user/login.twig')->withStatus(400);
} }
if (!$this->auth->verify($credentials['password'], $user->getPassword())) { if (!$this->auth->verify($credentials['password'], $user->getPassword())) {
$this->logger->error("Unable to verify user password."); $this->logger->error("Unable to verify user password.");
$this->session->getFlash()->add('error', "Unable to login user."); $this->session
->getFlash()
->add('error', "Unable to login user.");
return $this->render('user/login.twig')->withStatus(400); return $this->render('user/login.twig')->withStatus(400);
} }

View File

@ -1,9 +1,19 @@
{% for message in flash.get('success') %}
<div class="flash success">
{{ message }}
</div>
{% endfor %}
{% for message in flash.get('notice') %} {% for message in flash.get('notice') %}
<div class="flash notice"> <div class="flash notice">
{{ message }} {{ message }}
</div> </div>
{% endfor %} {% endfor %}
{% if flash.has('error') %}
<div>Hello!</div>
{% endif %}
{% for message in flash.get('error') %} {% for message in flash.get('error') %}
<div class="flash error"> <div class="flash error">
{{ message }} {{ message }}