diff --git a/app/src/Controller/User/LoginUserAction.php b/app/src/Controller/User/LoginUserAction.php index 85f1a57..3be71df 100644 --- a/app/src/Controller/User/LoginUserAction.php +++ b/app/src/Controller/User/LoginUserAction.php @@ -27,18 +27,24 @@ class LoginUserAction extends Controller $user = $this->userRepository->getFromEmail($credentials['email']); } catch (EntityNotFoundException $e) { $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); } if (!$this->auth->verify($credentials['password'], $user->getPassword())) { $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); } // start the session - $this->session->getFlash()->add('success', "Successfully loggedin."); + $this->session->getFlash()->add('success', "Successfully logged in."); $this->session->set('user', [ 'id' => $user->getId(), 'authenticated' => true ]); return $this->redirect('/dashboard', 302); } diff --git a/app/templates/layouts/components/flash.twig b/app/templates/layouts/components/flash.twig index 1593c13..fa1989d 100644 --- a/app/templates/layouts/components/flash.twig +++ b/app/templates/layouts/components/flash.twig @@ -1,9 +1,19 @@ +{% for message in flash.get('success') %} +
+ {{ message }} +
+{% endfor %} + {% for message in flash.get('notice') %}
{{ message }}
{% endfor %} +{% if flash.has('error') %} +
Hello!
+{% endif %} + {% for message in flash.get('error') %}
{{ message }}