X-Git-Url: https://git.rapsys.eu/userbundle/blobdiff_plain/feb820aea1304e9c63ca1aeca47bcaf0aa78b195..8a2af4135e032112590cca76e1645d2da0c97564:/Controller/UserController.php diff --git a/Controller/UserController.php b/Controller/UserController.php index 3698493..8f3e4f4 100644 --- a/Controller/UserController.php +++ b/Controller/UserController.php @@ -91,7 +91,7 @@ class UserController extends AbstractController { if (!($user = $this->doctrine->getRepository($this->config['class']['user'])->findOneByMail($mail))) { //Add error message mail already exists //XXX: prevent slugger reverse engineering by not displaying decoded mail - $this->addFlash('error', $this->translator->trans('Account %mail% do not exists', ['%mail%' => $smail])); + $this->addFlash('error', $this->translator->trans('Account do not exists')); //Redirect to register view return $this->redirectToRoute($this->config['route']['register']['name'], $this->config['route']['register']['context']); @@ -135,18 +135,18 @@ class UserController extends AbstractController { if (empty($user = $this->doctrine->getRepository($this->config['class']['user'])->findOneByMail($mail))) { //Throw not found //XXX: prevent slugger reverse engineering by not displaying decoded mail - throw $this->createNotFoundException($this->translator->trans('Unable to find account %mail%', ['%mail%' => $smail])); + throw $this->createNotFoundException($this->translator->trans('Unable to find account')); } //Prevent access when not admin, user is not guest and not currently logged user if (!$this->checker->isGranted($this->config['default']['admin']) && $user != $this->security->getUser() || !$this->checker->isGranted('IS_AUTHENTICATED_FULLY')) { //Throw access denied //XXX: prevent slugger reverse engineering by not displaying decoded mail - throw $this->createAccessDeniedException($this->translator->trans('Unable to access user: %mail%', ['%mail%' => $smail])); + throw $this->createAccessDeniedException($this->translator->trans('Unable to access user')); } //Create the EditType form and give the proper parameters - $edit = $this->createForm($this->config['edit']['view']['edit'], $user, [ + $edit = $this->factory->create($this->config['edit']['view']['edit'], $user, [ //Set action to edit route name and context 'action' => $this->generateUrl($this->config['route']['edit']['name'], ['mail' => $smail, 'hash' => $this->slugger->hash($smail)]+$this->config['route']['edit']['context']), //Set civility class @@ -160,7 +160,7 @@ class UserController extends AbstractController { //With admin role if ($this->checker->isGranted($this->config['default']['admin'])) { //Create the EditType form and give the proper parameters - $reset = $this->createForm($this->config['edit']['view']['reset'], $user, [ + $reset = $this->factory->create($this->config['edit']['view']['reset'], $user, [ //Set action to edit route name and context 'action' => $this->generateUrl($this->config['route']['edit']['name'], ['mail' => $smail, 'hash' => $this->slugger->hash($smail)]+$this->config['route']['edit']['context']), //Set method @@ -187,7 +187,7 @@ class UserController extends AbstractController { $this->manager->flush(); //Add notice - $this->addFlash('notice', $this->translator->trans('Account %mail% password updated', ['%mail%' => $mail = $data->getMail()])); + $this->addFlash('notice', $this->translator->trans('Account password updated')); //Redirect to cleanup the form return $this->redirectToRoute($this->config['route']['edit']['name'], ['mail' => $smail = $this->slugger->short($mail), 'hash' => $this->slugger->hash($smail)]+$this->config['route']['edit']['context']); @@ -217,14 +217,14 @@ class UserController extends AbstractController { $this->manager->flush(); //Add notice - $this->addFlash('notice', $this->translator->trans('Account %mail% updated', ['%mail%' => $mail = $data->getMail()])); + $this->addFlash('notice', $this->translator->trans('Account updated')); //Redirect to cleanup the form return $this->redirectToRoute($this->config['route']['edit']['name'], ['mail' => $smail = $this->slugger->short($mail), 'hash' => $this->slugger->hash($smail)]+$this->config['route']['edit']['context']); //Catch double slug or mail } catch (UniqueConstraintViolationException $e) { //Add error message mail already exists - $this->addFlash('error', $this->translator->trans('Account %mail% already exists', ['%mail%' => $data->getMail()])); + $this->addFlash('error', $this->translator->trans('Account already exists')); } } //Without admin role @@ -254,7 +254,7 @@ class UserController extends AbstractController { */ public function login(Request $request, AuthenticationUtils $authenticationUtils, ?string $hash, ?string $mail): Response { //Create the LoginType form and give the proper parameters - $login = $this->createForm($this->config['login']['view']['form'], null, [ + $login = $this->factory->create($this->config['login']['view']['form'], null, [ //Set action to login route name and context 'action' => $this->generateUrl($this->config['route']['login']['name'], $this->config['route']['login']['context']), //Set method @@ -297,7 +297,7 @@ class UserController extends AbstractController { $login->get('mail')->addError(new FormError($error)); //Create the RecoverType form and give the proper parameters - $recover = $this->createForm($this->config['recover']['view']['form'], null, [ + $recover = $this->factory->create($this->config['recover']['view']['form'], null, [ //Set action to recover route name and context 'action' => $this->generateUrl($this->config['route']['recover']['name'], $this->config['route']['recover']['context']), //Without password @@ -367,7 +367,7 @@ class UserController extends AbstractController { if (empty($user = $this->doctrine->getRepository($this->config['class']['user'])->findOneByMail($mail))) { //Throw not found //XXX: prevent slugger reverse engineering by not displaying decoded mail - throw $this->createNotFoundException($this->translator->trans('Unable to find account %mail%', ['%mail%' => $smail])); + throw $this->createNotFoundException($this->translator->trans('Unable to find account')); } //With unmatched pass @@ -382,7 +382,7 @@ class UserController extends AbstractController { } //Create the LoginType form and give the proper parameters - $form = $this->createForm($this->config['recover']['view']['form'], $user, [ + $form = $this->factory->create($this->config['recover']['view']['form'], $user, [ //Set action to recover route name and context 'action' => $this->generateUrl($this->config['route']['recover']['name'], $context+$this->config['route']['recover']['context']), //With user disable mail @@ -516,10 +516,10 @@ class UserController extends AbstractController { $this->mailer->send($message); //Add notice - $this->addFlash('notice', $this->translator->trans('Your recovery mail has been sent, to retrieve your account you must follow the recuperate link inside')); + $this->addFlash('notice', $this->translator->trans('Your recovery mail has been sent, to retrieve your account follow the recuperate link inside')); //Add junk warning - $this->addFlash('warning', $this->translator->trans('If you did not receive a recovery mail, check your Spam or Junk mail folders')); + $this->addFlash('warning', $this->translator->trans('If you did not receive a recovery mail, check your Spam or Junk mail folder')); //Redirect on the same route with sent=1 to cleanup form return $this->redirectToRoute($request->get('_route'), ['sent' => 1]+$request->get('_route_params'), 302); @@ -578,7 +578,7 @@ class UserController extends AbstractController { $user = $reflection->newInstance('', ''); //Create the RegisterType form and give the proper parameters - $form = $this->createForm($this->config['register']['view']['form'], $user, [ + $form = $this->factory->create($this->config['register']['view']['form'], $user, [ //Set action to register route name and context 'action' => $this->generateUrl($this->config['route']['register']['name'], $this->config['route']['register']['context']), //Set civility class @@ -707,7 +707,7 @@ class UserController extends AbstractController { $this->manager->flush(); //Add error message mail already exists - $this->addFlash('notice', $this->translator->trans('Your account has been created')); + $this->addFlash('notice', $this->translator->trans('Account created')); //Try sending message //XXX: mail delivery may silently fail