Optimized flash messages

This commit is contained in:
Kevin Frantz 2018-09-06 17:22:08 +02:00
parent 412c677c65
commit 56fb409477
3 changed files with 9 additions and 6 deletions

View File

@ -21,7 +21,7 @@ class SecurityController extends AbstractController
{
$error = $authenticationUtils->getLastAuthenticationError();
if ($error) {
$this->addFlash('notice', $error);
$this->addFlash('danger', $error->getMessage());
}
return $this->render("user/login.html.twig",[
'last_username'=>$authenticationUtils->getLastUsername(),

View File

@ -1,9 +1,9 @@
{% extends "base.html.twig" %}
{% block body %}
{% include 'frames/structure/navbar.html.twig'%}
{% include 'frames/structure/message/flash_messages.html.twig'%}
<br />
<div class="container">
{% include 'frames/structure/message/flash_messages.html.twig'%}
{% block content %}
{% endblock %}
</div>

View File

@ -1,5 +1,8 @@
{% for message in app.flashes('notice') %}
<div class="flash-notice">
{{ message }}
</div>
{% set icons = {'success':'fas fa-check-circle','danger':'fas fa-times','warning':'fas fa-exclamation-triangle','info':'fas fa-info'} %}
{% for label,messages in app.flashes %}
{% for message in messages %}
<div class="alert alert-{{ label }}">
<i class="{{ icons[label] }}"></i> {{ message }}
</div>
{% endfor %}
{% endfor %}