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
public function onDispatchError(MvcEvent $event)
{
$request = $event->getRequest();
$router = $event->getRouter();
if (!$request->isXmlHttpRequest()) {
return parent::onDispatchError($event);
}
if ($request->isXmlHttpRequest()) {
$sl = $event->getApplication()->getServiceManager();
$unauthorizedStrategy = $sl->get('BjyAuthorize\View\UnauthorizedStrategy'); /* @var $unauthorizedStrategy UnauthorizedStrategy */
$unauthorizedStrategy->onDispatchError($event);
return;
}
if (null === $this->redirectUri) {
if (($uri = $router->getRequestUri()) && $uri->getPath()) { /* @var $uri \Zend\Uri\Uri */
$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