Skip to content

Commit 212cce9

Browse files
committed
Merge pull request #13
2 parents c6a479f + d1a3253 commit 212cce9

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

src/Jmikola/AutoLogin/Http/Firewall/AutoLoginListener.php

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
1111
use Symfony\Component\HttpKernel\Log\LoggerInterface;
1212
use Symfony\Component\Security\Core\SecurityContextInterface;
13+
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
1314
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
1415
use Symfony\Component\Security\Core\Exception\AuthenticationException;
1516
use Symfony\Component\Security\Http\SecurityEvents;
@@ -29,16 +30,25 @@ class AutoLoginListener implements ListenerInterface
2930
/**
3031
* Constructor.
3132
*
32-
* @param SecurityContextInterface $securityContext
33-
* @param AuthenticationManagerInterface $authenticationManager
34-
* @param string $providerKey
35-
* @param string $tokenParam
36-
* @param LoggerInterface $logger
37-
* @param EventDispatcherInterface $dispatcher
38-
* @param array $options
33+
* @param TokenStorageInterface|SecurityContextInterface $securityContext
34+
* @param AuthenticationManagerInterface $authenticationManager
35+
* @param string $providerKey
36+
* @param string $tokenParam
37+
* @param LoggerInterface $logger
38+
* @param EventDispatcherInterface $dispatcher
39+
* @param array $options
3940
*/
40-
public function __construct(SecurityContextInterface $securityContext, AuthenticationManagerInterface $authenticationManager, $providerKey, $tokenParam, LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null, array $options = array())
41+
public function __construct($securityContext, AuthenticationManagerInterface $authenticationManager, $providerKey, $tokenParam, LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null, array $options = array())
4142
{
43+
if (!($securityContext instanceof SecurityContextInterface) &&
44+
!($securityContext instanceof TokenStorageInterface)) {
45+
throw new \InvalidArgumentException(sprintf(
46+
'Argument 1 passed to %s() must be an instance of Symfony\Component\Security\Core\SecurityContextInterface or Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface, %s given',
47+
__METHOD__,
48+
is_object($securityContext) ? get_class($securityContext) : gettype($securityContext)
49+
));
50+
}
51+
4252
$this->securityContext = $securityContext;
4353
$this->authenticationManager = $authenticationManager;
4454
$this->providerKey = $providerKey;

0 commit comments

Comments
 (0)