Commit 617d3ef9 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

AJout redirection vers la page demandée avant authentification.

parent e9c1b964
...@@ -20,13 +20,24 @@ class RedirectionStrategy extends \BjyAuthorize\View\RedirectionStrategy ...@@ -20,13 +20,24 @@ class RedirectionStrategy extends \BjyAuthorize\View\RedirectionStrategy
public function onDispatchError(MvcEvent $event) public function onDispatchError(MvcEvent $event)
{ {
$request = $event->getRequest(); $request = $event->getRequest();
$router = $event->getRouter();
if (!$request->isXmlHttpRequest()) { if ($request->isXmlHttpRequest()) {
return parent::onDispatchError($event); $sl = $event->getApplication()->getServiceManager();
$unauthorizedStrategy = $sl->get('BjyAuthorize\View\UnauthorizedStrategy'); /* @var $unauthorizedStrategy UnauthorizedStrategy */
$unauthorizedStrategy->onDispatchError($event);
return;
} }
$sl = $event->getApplication()->getServiceManager(); if (null === $this->redirectUri) {
$unauthorizedStrategy = $sl->get('BjyAuthorize\View\UnauthorizedStrategy'); /* @var $unauthorizedStrategy UnauthorizedStrategy */ if (($uri = $router->getRequestUri()) && $uri->getPath()) { /* @var $uri \Zend\Uri\Uri */
$unauthorizedStrategy->onDispatchError($event); $this->redirectUri = $router->assemble(array(), array(
'name' => $this->redirectRoute,
'query' => array('redirect' => urlencode($uri->toString()))));
}
}
parent::onDispatchError($event);
} }
} }
\ No newline at end of file
Supports Markdown
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