Commit 46e7086a by Damien Moulard

add flash message to confirm password update event if user not connected

parent 047d62d3
...@@ -6,14 +6,17 @@ use FOS\UserBundle\FOSUserEvents; ...@@ -6,14 +6,17 @@ use FOS\UserBundle\FOSUserEvents;
use FOS\UserBundle\Event\FilterUserResponseEvent; use FOS\UserBundle\Event\FilterUserResponseEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\HttpFoundation\RequestStack;
class PreventDisabledUserAutoLoginListener implements EventSubscriberInterface class PreventDisabledUserAutoLoginListener implements EventSubscriberInterface
{ {
private $tokenStorage; private $tokenStorage;
private $requestStack;
public function __construct(TokenStorageInterface $tokenStorage) public function __construct(TokenStorageInterface $tokenStorage, RequestStack $requestStack)
{ {
$this->tokenStorage = $tokenStorage; $this->tokenStorage = $tokenStorage;
$this->requestStack = $requestStack;
} }
public static function getSubscribedEvents() public static function getSubscribedEvents()
...@@ -28,6 +31,12 @@ class PreventDisabledUserAutoLoginListener implements EventSubscriberInterface ...@@ -28,6 +31,12 @@ class PreventDisabledUserAutoLoginListener implements EventSubscriberInterface
$user = $event->getUser(); $user = $event->getUser();
if (!$user->isEnabled()) { if (!$user->isEnabled()) {
// Add flash message before deleting token
$request = $this->requestStack->getCurrentRequest();
if ($request) {
$request->getSession()->getFlashBag()->add('success', 'Votre mot de passe a été modifié. Vous pourrez vous connecter lorsque votre compte sera activé.');
}
// Delete authentication token so disabled user isn't automaticaly connected after resetting password // Delete authentication token so disabled user isn't automaticaly connected after resetting password
$this->tokenStorage->setToken(null); $this->tokenStorage->setToken(null);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment