]> Raphaƫl G. Git Repositories - userbundle/blobdiff - Controller/UserController.php
Enable register captcha
[userbundle] / Controller / UserController.php
index 8f3e4f41ad6015b35a0b2cb784d2f37dacdaaa81..4058c9134d0efaef194fde84926053dedf46244b 100644 (file)
@@ -12,6 +12,9 @@
 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;
@@ -22,8 +25,6 @@ use Symfony\Component\Mime\Address;
 use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
 use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
 
-use Rapsys\UserBundle\RapsysUserBundle;
-
 /**
  * {@inheritdoc}
  */
@@ -495,7 +496,7 @@ class UserController extends AbstractController {
                                        //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']))
@@ -553,7 +554,7 @@ class UserController extends AbstractController {
                        //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(),
@@ -565,7 +566,8 @@ class UserController extends AbstractController {
                                                                'hash' => $this->slugger->hash($postSmail)
                                                        ]+$this->config['route']['confirm']['context'],
                                                        UrlGeneratorInterface::ABSOLUTE_URL
-                                               )
+                                               ),
+                                               '%ip%' => $request->getClientIp()
                                        ]
                                )
                        );
@@ -581,6 +583,8 @@ class UserController extends AbstractController {
                $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 captcha
+                       'captcha' => true,
                        //Set civility class
                        'civility_class' => $this->config['class']['civility'],
                        //Set civility default
@@ -687,7 +691,7 @@ class UserController extends AbstractController {
                                //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']))