|
13 | 13 |
|
14 | 14 | namespace CCDNUser\SecurityBundle\Component\Listener; |
15 | 15 |
|
16 | | -use Symfony\Component\HttpKernel\Exception\HttpException; |
| 16 | +use CCDNUser\SecurityBundle\Component\Authorisation\SecurityManager; |
17 | 17 | use Symfony\Component\HttpKernel\Event\GetResponseEvent; |
18 | 18 | use Symfony\Component\HttpFoundation\RedirectResponse; |
19 | 19 | use Symfony\Component\Routing\RouterInterface; |
@@ -52,18 +52,25 @@ class BlockingLoginListener |
52 | 52 | */ |
53 | 53 | protected $securityManager; |
54 | 54 |
|
| 55 | + /** |
| 56 | + * @var AccessDeniedExceptionFactoryInterface |
| 57 | + */ |
| 58 | + protected $exceptionFactory; |
| 59 | + |
55 | 60 | /** |
56 | 61 | * |
57 | 62 | * @access public |
58 | | - * @param \Symfony\Component\Routing\RouterInterface $router |
59 | | - * @param \CCDNUser\SecurityBundle\Component\Authorisation\SecurityManager $loginFailureTracker |
60 | | - * @param array $forceAccountRecovery |
| 63 | + * @param \Symfony\Component\Routing\RouterInterface $router |
| 64 | + * @param \CCDNUser\SecurityBundle\Component\Authorisation\SecurityManager $loginFailureTracker |
| 65 | + * @param \CCDNUser\SecurityBundle\Component\Listener\AccessDeniedExceptionFactoryInterface $exceptionFactory |
| 66 | + * @param array $forceAccountRecovery |
61 | 67 | */ |
62 | | - public function __construct(RouterInterface $router, $securityManager, $forceAccountRecovery) |
| 68 | + public function __construct(RouterInterface $router, SecurityManager $securityManager, AccessDeniedExceptionFactoryInterface $exceptionFactory, $forceAccountRecovery) |
63 | 69 | { |
64 | 70 | $this->securityManager = $securityManager; |
65 | 71 | $this->router = $router; |
66 | 72 | $this->forceAccountRecovery = $forceAccountRecovery; |
| 73 | + $this->exceptionFactory = $exceptionFactory; |
67 | 74 | } |
68 | 75 |
|
69 | 76 | /** |
@@ -101,7 +108,7 @@ public function onKernelRequest(GetResponseEvent $event) |
101 | 108 | if ($result == $securityManager::ACCESS_DENIED_BLOCK) { |
102 | 109 | $event->stopPropagation(); |
103 | 110 |
|
104 | | - throw new HttpException(500, 'flood control - login blocked'); |
| 111 | + throw $this->exceptionFactory->createAccessDeniedException(); |
105 | 112 | } |
106 | 113 | } |
107 | 114 | } |
0 commit comments