]> Raphaƫl G. Git Repositories - userbundle/blobdiff - Controller/UserController.php
Cleanup
[userbundle] / Controller / UserController.php
index cce4deb3a4fd6263c38104c15f8cb36355de130d..73f02ea03c446ebea2195177d259049287be597f 100644 (file)
@@ -12,6 +12,9 @@
 namespace Rapsys\UserBundle\Controller;
 
 use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
 namespace Rapsys\UserBundle\Controller;
 
 use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
+
+use Rapsys\UserBundle\RapsysUserBundle;
+
 use Symfony\Bridge\Twig\Mime\TemplatedEmail;
 use Symfony\Component\Form\FormError;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Bridge\Twig\Mime\TemplatedEmail;
 use Symfony\Component\Form\FormError;
 use Symfony\Component\HttpFoundation\Request;
@@ -22,8 +25,6 @@ use Symfony\Component\Mime\Address;
 use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
 use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
 
 use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
 use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
 
-use Rapsys\UserBundle\RapsysUserBundle;
-
 /**
  * {@inheritdoc}
  */
 /**
  * {@inheritdoc}
  */
@@ -146,7 +147,7 @@ class UserController extends AbstractController {
                }
 
                //Create the EditType form and give the proper parameters
                }
 
                //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
                        //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 +161,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
                //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
                                //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
@@ -254,7 +255,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
         */
        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
                        //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 +298,7 @@ class UserController extends AbstractController {
                        $login->get('mail')->addError(new FormError($error));
 
                        //Create the RecoverType form and give the proper parameters
                        $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
                                //Set action to recover route name and context
                                'action' => $this->generateUrl($this->config['route']['recover']['name'], $this->config['route']['recover']['context']),
                                //Without password
@@ -382,7 +383,7 @@ class UserController extends AbstractController {
                }
 
                //Create the LoginType form and give the proper parameters
                }
 
                //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
                        //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
@@ -495,7 +496,7 @@ class UserController extends AbstractController {
                                        //Create message
                                        $message = (new TemplatedEmail())
                                                //Set sender
                                        //Create message
                                        $message = (new TemplatedEmail())
                                                //Set sender
-                                               ->from(new Address($this->config['contact']['address'], $this->config['contact']['name']))
+                                               ->from(new Address($this->config['contact']['address'], $this->translator->trans($this->config['contact']['name'])))
                                                //Set recipient
                                                //XXX: remove the debug set in vendor/symfony/mime/Address.php +46
                                                ->to(new Address($context['recipient_mail'], $context['recipient_name']))
                                                //Set recipient
                                                //XXX: remove the debug set in vendor/symfony/mime/Address.php +46
                                                ->to(new Address($context['recipient_mail'], $context['recipient_name']))
@@ -553,7 +554,7 @@ class UserController extends AbstractController {
                        //Log new user infos
                        $this->logger->emergency(
                                $this->translator->trans(
                        //Log new user infos
                        $this->logger->emergency(
                                $this->translator->trans(
-                                       'register: mail=%mail% locale=%locale% confirm=%confirm%',
+                                       'register: mail=%mail% locale=%locale% confirm=%confirm% ip=%ip%',
                                        [
                                                '%mail%' => $postMail = $_POST['register']['mail'],
                                                '%locale%' => $request->getLocale(),
                                        [
                                                '%mail%' => $postMail = $_POST['register']['mail'],
                                                '%locale%' => $request->getLocale(),
@@ -565,7 +566,8 @@ class UserController extends AbstractController {
                                                                'hash' => $this->slugger->hash($postSmail)
                                                        ]+$this->config['route']['confirm']['context'],
                                                        UrlGeneratorInterface::ABSOLUTE_URL
                                                                'hash' => $this->slugger->hash($postSmail)
                                                        ]+$this->config['route']['confirm']['context'],
                                                        UrlGeneratorInterface::ABSOLUTE_URL
-                                               )
+                                               ),
+                                               '%ip%' => $request->getClientIp()
                                        ]
                                )
                        );
                                        ]
                                )
                        );
@@ -578,7 +580,7 @@ class UserController extends AbstractController {
                $user = $reflection->newInstance('', '');
 
                //Create the RegisterType form and give the proper parameters
                $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
                        //Set action to register route name and context
                        'action' => $this->generateUrl($this->config['route']['register']['name'], $this->config['route']['register']['context']),
                        //Set civility class
@@ -687,7 +689,7 @@ class UserController extends AbstractController {
                                //Create message
                                $message = (new TemplatedEmail())
                                        //Set sender
                                //Create message
                                $message = (new TemplatedEmail())
                                        //Set sender
-                                       ->from(new Address($this->config['contact']['address'], $this->config['contact']['name']))
+                                       ->from(new Address($this->config['contact']['address'], $this->translator->trans($this->config['contact']['name'])))
                                        //Set recipient
                                        //XXX: remove the debug set in vendor/symfony/mime/Address.php +46
                                        ->to(new Address($context['recipient_mail'], $context['recipient_name']))
                                        //Set recipient
                                        //XXX: remove the debug set in vendor/symfony/mime/Address.php +46
                                        ->to(new Address($context['recipient_mail'], $context['recipient_name']))