From: Raphaƫl Gertz <git@rapsys.eu>
Date: Sat, 28 Aug 2021 11:06:32 +0000 (+0200)
Subject: Fix reset password message display condition
X-Git-Tag: 0.2.0~19
X-Git-Url: https://git.rapsys.eu/userbundle/commitdiff_plain/df726f2d87a8dd94b8fdae19d8828572d5a1713e

Fix reset password message display condition
Remove slug reference
---

diff --git a/Controller/DefaultController.php b/Controller/DefaultController.php
index c431b5d..070df0c 100644
--- a/Controller/DefaultController.php
+++ b/Controller/DefaultController.php
@@ -183,11 +183,6 @@ class DefaultController extends AbstractController {
 
 			//Add reset view
 			$this->config['edit']['view']['context']['reset'] = $reset->createView();
-		//Without admin role
-		//XXX: prefer a reset on login to force user unspam action
-		} else {
-			//Add notice
-			$this->addFlash('notice', $this->translator->trans('To change your password login with your mail and any password then follow the procedure'));
 		}
 
 		//With post method
@@ -216,9 +211,14 @@ class DefaultController extends AbstractController {
 				//Catch double slug or mail
 				} catch (UniqueConstraintViolationException $e) {
 					//Add error message mail already exists
-					$this->addFlash('error', $this->translator->trans('Account %mail% or with slug %slug% already exists', ['%mail%' => $data->getMail(), '%slug%' => $slug]));
+					$this->addFlash('error', $this->translator->trans('Account %mail% already exists', ['%mail%' => $data->getMail()]));
 				}
 			}
+		//Without admin role
+		//XXX: prefer a reset on login to force user unspam action
+		} elseif (!$this->isGranted('ROLE_ADMIN')) {
+			//Add notice
+			$this->addFlash('notice', $this->translator->trans('To change your password login with your mail and any password then follow the procedure'));
 		}
 
 		//Render view