Commit c210e423 by Julien Jorry

Fix redirection after changing role

parent 4792371e
...@@ -33,6 +33,7 @@ use Symfony\Component\HttpFoundation\Request; ...@@ -33,6 +33,7 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Session\SessionInterface; use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Security as Secur; use Symfony\Component\Security\Core\Security as Secur;
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface; use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
...@@ -49,8 +50,9 @@ class IndexController extends AbstractController ...@@ -49,8 +50,9 @@ class IndexController extends AbstractController
private $authenticator; private $authenticator;
private $session; private $session;
private $tokenStorage; private $tokenStorage;
private $router;
public function __construct(EventDispatcherInterface $eventDispatcher, EntityManagerInterface $em, UserManagerInterface $userManager, CsrfTokenManagerInterface $tokenManager = null, GuardAuthenticatorHandler $guard, SessionInterface $session, LoginAuthenticator $authenticator, TokenStorageInterface $tokenStorage) public function __construct(EventDispatcherInterface $eventDispatcher, EntityManagerInterface $em, UserManagerInterface $userManager, CsrfTokenManagerInterface $tokenManager = null, GuardAuthenticatorHandler $guard, SessionInterface $session, LoginAuthenticator $authenticator, TokenStorageInterface $tokenStorage, RouterInterface $router)
{ {
$this->eventDispatcher = $eventDispatcher; $this->eventDispatcher = $eventDispatcher;
$this->em = $em; $this->em = $em;
...@@ -60,6 +62,7 @@ class IndexController extends AbstractController ...@@ -60,6 +62,7 @@ class IndexController extends AbstractController
$this->authenticator = $authenticator; $this->authenticator = $authenticator;
$this->session = $session; $this->session = $session;
$this->tokenStorage = $tokenStorage; $this->tokenStorage = $tokenStorage;
$this->router = $router;
} }
/** /**
...@@ -434,13 +437,12 @@ class IndexController extends AbstractController ...@@ -434,13 +437,12 @@ class IndexController extends AbstractController
$this->removeOldSessionParams(); $this->removeOldSessionParams();
$this->reloadUserTokenFromGroup($group, $request); $this->reloadUserTokenFromGroup($group, $request);
// @TODO : On redirige sur l'index (ou en fonction du rôle?) if (in_array('ROLE_SUPER_ADMIN', $this->getUser()->getRoles(), true)) {
$referer = $request->headers->get('referer'); // c'est un administrateur
if ($referer && !$request->isXmlHttpRequest()) { return new RedirectResponse($this->router->generate('sonata_admin_dashboard'));
return $this->redirect($referer);
} elseif (!$request->isXmlHttpRequest()) {
return $this->redirectToRoute('index');
} }
return new RedirectResponse($this->router->generate('index'));
} }
private function removeOldSessionParams() private function removeOldSessionParams()
......
...@@ -60,6 +60,7 @@ class MLCEventListener implements EventSubscriberInterface ...@@ -60,6 +60,7 @@ class MLCEventListener implements EventSubscriberInterface
MLCEvents::REGISTRATION_PRESTATAIRE => 'onRegistrationPrestataire', MLCEvents::REGISTRATION_PRESTATAIRE => 'onRegistrationPrestataire',
MLCEvents::REGISTRATION_CAISSIER => 'onRegistrationCaissier', MLCEvents::REGISTRATION_CAISSIER => 'onRegistrationCaissier',
MLCEvents::FLUX => 'onFlux', MLCEvents::FLUX => 'onFlux',
// @TODO : checker si VALIDATE_DEMANDE_ACHAT_EMLC c'est toujours d'actualité et utile ?
MLCEvents::VALIDATE_DEMANDE_ACHAT_EMLC => 'onValidateDemandeAchatEmlc', MLCEvents::VALIDATE_DEMANDE_ACHAT_EMLC => 'onValidateDemandeAchatEmlc',
MLCEvents::CHANGE_PRESTATAIRE_COMPTOIR => 'onChange', MLCEvents::CHANGE_PRESTATAIRE_COMPTOIR => 'onChange',
MLCEvents::CHANGE_ADHERENT_COMPTOIR => 'onChange', MLCEvents::CHANGE_ADHERENT_COMPTOIR => 'onChange',
...@@ -257,6 +258,7 @@ class MLCEventListener implements EventSubscriberInterface ...@@ -257,6 +258,7 @@ class MLCEventListener implements EventSubscriberInterface
$template = '@kohinos/email/flux/' . $type . '_' . $flux->getParentType() . '-' . $flux->getType() . '.html.twig'; $template = '@kohinos/email/flux/' . $type . '_' . $flux->getParentType() . '-' . $flux->getType() . '.html.twig';
} }
} }
return $template; return $template;
} }
......
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