Skip to content

Commit 104e486

Browse files
authored
Merge pull request #3056 from stof/fix_confirmation_email
Fix the access to the session in the email confirmation listener
2 parents fab5b63 + 6b495f1 commit 104e486

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

EventListener/EmailConfirmationListener.php

+2-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use FOS\UserBundle\Util\TokenGeneratorInterface;
1818
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
1919
use Symfony\Component\HttpFoundation\RedirectResponse;
20-
use Symfony\Component\HttpFoundation\Session\SessionInterface;
2120
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
2221

2322
/**
@@ -30,17 +29,15 @@ class EmailConfirmationListener implements EventSubscriberInterface
3029
private $mailer;
3130
private $tokenGenerator;
3231
private $router;
33-
private $session;
3432

3533
/**
3634
* EmailConfirmationListener constructor.
3735
*/
38-
public function __construct(MailerInterface $mailer, TokenGeneratorInterface $tokenGenerator, UrlGeneratorInterface $router, SessionInterface $session)
36+
public function __construct(MailerInterface $mailer, TokenGeneratorInterface $tokenGenerator, UrlGeneratorInterface $router)
3937
{
4038
$this->mailer = $mailer;
4139
$this->tokenGenerator = $tokenGenerator;
4240
$this->router = $router;
43-
$this->session = $session;
4441
}
4542

4643
public static function getSubscribedEvents(): array
@@ -62,7 +59,7 @@ public function onRegistrationSuccess(FormEvent $event)
6259

6360
$this->mailer->sendConfirmationEmailMessage($user);
6461

65-
$this->session->set('fos_user_send_confirmation_email/email', $user->getEmail());
62+
$event->getRequest()->getSession()->set('fos_user_send_confirmation_email/email', $user->getEmail());
6663

6764
$url = $this->router->generate('fos_user_registration_check_email');
6865
$event->setResponse(new RedirectResponse($url));

Resources/config/email_confirmation.xml

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
<argument type="service" id="fos_user.mailer" />
1111
<argument type="service" id="fos_user.util.token_generator" />
1212
<argument type="service" id="router" />
13-
<argument type="service" id="session" />
1413
</service>
1514
</services>
1615

0 commit comments

Comments
 (0)