|
@@ -17,7 +17,6 @@ use Symfony\Component\HttpFoundation\RedirectResponse;
|
|
use Symfony\Component\Security\Core\Exception\AuthenticationException;
|
|
use Symfony\Component\Security\Core\Exception\AuthenticationException;
|
|
use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;
|
|
use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;
|
|
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
|
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
|
-use Symfony\Component\HttpKernel\Event\GetResponseEvent;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* FormAuthenticationEntryPoint starts an authentication via a login form.
|
|
* FormAuthenticationEntryPoint starts an authentication via a login form.
|
|
@@ -28,15 +27,18 @@ class FormAuthenticationEntryPoint implements AuthenticationEntryPointInterface
|
|
{
|
|
{
|
|
private $loginPath;
|
|
private $loginPath;
|
|
private $useForward;
|
|
private $useForward;
|
|
|
|
+ private $httpKernel;
|
|
|
|
|
|
/**
|
|
/**
|
|
* Constructor
|
|
* Constructor
|
|
*
|
|
*
|
|
|
|
+ * @param HttpKernelInterface $kernel
|
|
* @param string $loginPath The path to the login form
|
|
* @param string $loginPath The path to the login form
|
|
* @param Boolean $useForward Whether to forward or redirect to the login form
|
|
* @param Boolean $useForward Whether to forward or redirect to the login form
|
|
*/
|
|
*/
|
|
- public function __construct($loginPath, $useForward = false)
|
|
|
|
|
|
+ public function __construct(HttpKernelInterface $kernel, $loginPath, $useForward = false)
|
|
{
|
|
{
|
|
|
|
+ $this->httpKernel = $kernel;
|
|
$this->loginPath = $loginPath;
|
|
$this->loginPath = $loginPath;
|
|
$this->useForward = (Boolean) $useForward;
|
|
$this->useForward = (Boolean) $useForward;
|
|
}
|
|
}
|
|
@@ -44,10 +46,10 @@ class FormAuthenticationEntryPoint implements AuthenticationEntryPointInterface
|
|
/**
|
|
/**
|
|
* {@inheritdoc}
|
|
* {@inheritdoc}
|
|
*/
|
|
*/
|
|
- public function start(GetResponseEvent $event, Request $request, AuthenticationException $authException = null)
|
|
|
|
|
|
+ public function start(Request $request, AuthenticationException $authException = null)
|
|
{
|
|
{
|
|
if ($this->useForward) {
|
|
if ($this->useForward) {
|
|
- return $event->getKernel()->handle(Request::create($this->loginPath), HttpKernelInterface::SUB_REQUEST);
|
|
|
|
|
|
+ return $this->httpKernel->handle(Request::create($this->loginPath), HttpKernelInterface::SUB_REQUEST);
|
|
}
|
|
}
|
|
|
|
|
|
return new RedirectResponse(0 !== strpos($this->loginPath, 'http') ? $request->getUriForPath($this->loginPath) : $this->loginPath, 302);
|
|
return new RedirectResponse(0 !== strpos($this->loginPath, 'http') ? $request->getUriForPath($this->loginPath) : $this->loginPath, 302);
|