From ce3f908033ba7d3128d0f99114e7b015bc19f59f Mon Sep 17 00:00:00 2001
From: Camille Simiand <camille.simiand@tetras-libre.fr>
Date: Mon, 14 Mar 2022 16:23:54 +0100
Subject: [PATCH] Uniformize flashMessages refacto

---
 src/Controller/RegistrationController.php         | 2 +-
 src/Controller/ResetPasswordController.php        | 2 +-
 src/Controller/UserController.php                 | 2 +-
 templates/capsule/editors/list_editors.html.twig  | 4 ++--
 templates/capsule/groups/capsule_groups.html.twig | 4 ++--
 templates/capsule/groups/user_groups.html.twig    | 4 ++--
 templates/capsule/index.html.twig                 | 4 ++--
 templates/registration/register.html.twig         | 2 +-
 templates/reset_password/request.html.twig        | 6 ++++--
 templates/security/login.html.twig                | 6 ++++--
 templates/user/profile.html.twig                  | 4 ++--
 11 files changed, 22 insertions(+), 18 deletions(-)

diff --git a/src/Controller/RegistrationController.php b/src/Controller/RegistrationController.php
index e641063..abd35e4 100755
--- a/src/Controller/RegistrationController.php
+++ b/src/Controller/RegistrationController.php
@@ -100,7 +100,7 @@ class RegistrationController extends AbstractController
         $this->addCapsuleToConfirmedPreviousPendingEditor($user);
 
         $this->addFlash(
-            'email_verified_success',
+            'success',
             $translator->trans('registration.email_verified_success')
         );
 
diff --git a/src/Controller/ResetPasswordController.php b/src/Controller/ResetPasswordController.php
index a58c51a..7cb9a8c 100755
--- a/src/Controller/ResetPasswordController.php
+++ b/src/Controller/ResetPasswordController.php
@@ -86,7 +86,7 @@ class ResetPasswordController extends AbstractController
                 throw new \Exception("User should be an instance of UserPasswordHasherInterface");
             }
         } catch (ResetPasswordExceptionInterface $e) {
-            $this->addFlash('reset_password_error', sprintf(
+            $this->addFlash('error', sprintf(
                 'There was a problem validating your reset request - %s',
                 $e->getReason()
             ));
diff --git a/src/Controller/UserController.php b/src/Controller/UserController.php
index 89f7eca..62c6550 100755
--- a/src/Controller/UserController.php
+++ b/src/Controller/UserController.php
@@ -133,7 +133,7 @@ class UserController extends AbstractController
             $this->entity_manager->flush();
 
             $this->addFlash(
-                'profile_updated_success',
+                'success',
                 $this->translator->trans('user.password.updated_success')
             );
 
diff --git a/templates/capsule/editors/list_editors.html.twig b/templates/capsule/editors/list_editors.html.twig
index 0b71139..222c515 100644
--- a/templates/capsule/editors/list_editors.html.twig
+++ b/templates/capsule/editors/list_editors.html.twig
@@ -18,13 +18,13 @@
         </div>
 
         {% for flashWarning in app.flashes('warning') %}
-            <div class="text-center alert alert-warning col-11 col-md-10 col-lg-9 col-xl-8 mx-auto my-5 mt-2" role="alert">
+            <div class="text-center alert alert-warning col-11 col-md-10 col-lg-8 col-xl-6 mx-auto mb-5" role="alert">
                 {{ flashWarning }}
             </div>
         {% endfor %}
 
         {% for flashSuccess in app.flashes('success') %}
-            <div class="text-center alert alert-success col-11 col-md-10 col-lg-9 col-xl-8 mx-auto my-5 mt-2" role="alert">
+            <div class="text-center alert alert-success col-11 col-md-10 col-lg-8 col-xl-6 mx-auto mb-5" role="alert">
                 {{ flashSuccess }}
             </div>
         {% endfor %}
diff --git a/templates/capsule/groups/capsule_groups.html.twig b/templates/capsule/groups/capsule_groups.html.twig
index ad38080..02c0a82 100644
--- a/templates/capsule/groups/capsule_groups.html.twig
+++ b/templates/capsule/groups/capsule_groups.html.twig
@@ -18,13 +18,13 @@
         </div>
 
         {% for flashWarning in app.flashes('warning') %}
-            <div class="text-center alert alert-warning col-11 col-md-10 col-lg-9 col-xl-8 mx-auto my-5 mt-2" role="alert">
+            <div class="text-center alert alert-warning col-11 col-md-10 col-lg-8 col-xl-6 mx-auto mb-5" role="alert">
                 {{ flashWarning }}
             </div>
         {% endfor %}
 
         {% for flashSuccess in app.flashes('success') %}
-            <div class="text-center alert alert-success col-11 col-md-10 col-lg-9 col-xl-8 mx-auto my-5 mt-2" role="alert">
+            <div class="text-center alert alert-success col-11 col-md-10 col-lg-8 col-xl-6 mx-auto mb-5" role="alert">
                 {{ flashSuccess }}
             </div>
         {% endfor %}
diff --git a/templates/capsule/groups/user_groups.html.twig b/templates/capsule/groups/user_groups.html.twig
index 808b416..d2096e4 100644
--- a/templates/capsule/groups/user_groups.html.twig
+++ b/templates/capsule/groups/user_groups.html.twig
@@ -17,13 +17,13 @@
         </div>
 
         {% for flashWarning in app.flashes('warning') %}
-            <div class="text-center alert alert-warning col-11 col-md-10 col-lg-9 col-xl-8 mx-auto my-5 mt-2" role="alert">
+            <div class="text-center alert alert-warning col-11 col-md-10 col-lg-8 col-xl-6 mx-auto mb-5" role="alert">
                 {{ flashWarning }}
             </div>
         {% endfor %}
 
         {% for flashSuccess in app.flashes('success') %}
-            <div class="text-center alert alert-success col-11 col-md-10 col-lg-9 col-xl-8 mx-auto my-5 mt-2" role="alert">
+            <div class="text-center alert alert-success col-11 col-md-10 col-lg-8 col-xl-6 mx-auto mb-5" role="alert">
                 {{ flashSuccess }}
             </div>
         {% endfor %}
diff --git a/templates/capsule/index.html.twig b/templates/capsule/index.html.twig
index 59b64db..1a9c226 100644
--- a/templates/capsule/index.html.twig
+++ b/templates/capsule/index.html.twig
@@ -34,13 +34,13 @@
     </div>
 
     {% for flashWarning in app.flashes('warning') %}
-        <div class="text-center alert alert-warning col-11 col-md-10 col-lg-9 col-xl-8 mx-auto my-5" role="alert">
+        <div class="text-center alert alert-warning col-11 col-md-10 col-lg-8 col-xl-6 mx-auto mb-5" role="alert">
             {{ flashWarning }}
         </div>
     {% endfor %}
 
     {% for flashSuccess in app.flashes('success') %}
-        <div class="text-center alert alert-success col-11 col-md-10 col-lg-9 col-xl-8 mx-auto my-5" role="alert">
+        <div class="text-center alert alert-success col-11 col-md-10 col-lg-8 col-xl-6 mx-auto mb-5" role="alert">
             {{ flashSuccess }}
         </div>
     {% endfor %}
diff --git a/templates/registration/register.html.twig b/templates/registration/register.html.twig
index 99d5864..de27d29 100644
--- a/templates/registration/register.html.twig
+++ b/templates/registration/register.html.twig
@@ -7,7 +7,7 @@
 {% block body %}
   <div class="mt-4">
     {% for flashError in app.flashes('error') %}
-      <div class="alert alert-danger col-11 col-md-10 col-lg-9 col-xl-8 mx-auto my-5 h1" role="alert">
+      <div class="alert alert-danger col-11 col-md-10 col-lg-8 col-xl-6 mx-auto mb-5 h1" role="alert">
           {{ flashError }}
       </div>
     {% endfor %}
diff --git a/templates/reset_password/request.html.twig b/templates/reset_password/request.html.twig
index 5cc417e..6caf46d 100644
--- a/templates/reset_password/request.html.twig
+++ b/templates/reset_password/request.html.twig
@@ -5,8 +5,10 @@
 {% endblock %}
 
 {% block body %}
-    {% for flashError in app.flashes('reset_password_error') %}
-        <div class="alert alert-danger" role="alert">{{ flashError }}</div>
+    {% for flashError in app.flashes('error') %}
+        <div class="text-center alert alert-danger col-11 col-md-10 col-lg-8 col-xl-6 mx-auto mb-5" role="alert">
+            {{ flashError }}
+        </div>
     {% endfor %}
     <h1 class="m-auto mb-4 mt-4 col-6">
         {{ 'reset_password.title'|trans }}
diff --git a/templates/security/login.html.twig b/templates/security/login.html.twig
index aff2910..a449511 100644
--- a/templates/security/login.html.twig
+++ b/templates/security/login.html.twig
@@ -8,8 +8,10 @@
     {% if error %}
         <div class="alert alert-danger col-6 m-auto">{{ error.messageKey|trans(error.messageData, 'security') }}</div>
     {% endif %}
-    {% for flashMessage in app.flashes('email_verified_success') %}
-        <div class="text-center alert alert-warning col-6 m-auto" role="alert" >{{ flashMessage }}</div>
+    {% for flashMessage in app.flashes('error') %}
+        <div class="text-center alert alert-warning col-11 col-md-10 col-lg-8 col-xl-6 mx-auto mb-5" role="alert" >
+            {{ flashMessage }}
+        </div>
     {% endfor %}
 
 <form method="post" class="d-flex flex-column justify-content-center">
diff --git a/templates/user/profile.html.twig b/templates/user/profile.html.twig
index d6e8080..1aff1e1 100644
--- a/templates/user/profile.html.twig
+++ b/templates/user/profile.html.twig
@@ -14,13 +14,13 @@
     </div>
 
     {% for flashSuccess in app.flashes('success') %}
-        <div class="text-center alert alert-success col-11 col-md-10 col-lg-9 col-xl-8 mx-auto mt-0 mb-4" role="alert">
+        <div class="text-center alert alert-success col-11 col-md-10 col-lg-8 col-xl-6 mx-auto mb-5" role="alert">
             {{ flashSuccess }}
         </div>
     {% endfor %}
 
     {% for flashWarning in app.flashes('warning') %}
-        <div class="text-center alert alert-warning col-11 col-md-10 col-lg-9 col-xl-8 mx-auto mt-0 mb-4" role="alert">
+        <div class="text-center alert alert-warning col-11 col-md-10 col-lg-8 col-xl-6 mx-auto mb-5" role="alert">
             {{ flashWarning }}
         </div>
     {% endfor %}
-- 
GitLab