vendor/simpledot/cms-bundle/AWCmsBundle/Handler/LoginFailureHandler.php line 51

Open in your IDE?
  1. <?php
  2. namespace AWCmsBundle\Handler;
  3. use Anyx\LoginGateBundle\Event\BruteForceAttemptEvent;
  4. use Symfony\Bundle\FrameworkBundle\Translation\Translator;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. use Symfony\Component\HttpFoundation\Session\Session;
  7. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  8. use Symfony\Component\HttpKernel\KernelEvents;
  9. use Symfony\Component\Routing\RouterInterface;
  10. use Symfony\Component\Security\Core\AuthenticationEvents;
  11. use Symfony\Component\Security\Core\Exception\AccountExpiredException;
  12. use Symfony\Component\Security\Core\Exception\AccountStatusException;
  13. use Symfony\Component\Security\Core\Exception\AuthenticationException;
  14. use Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface;
  15. use Symfony\Component\HttpFoundation\Request;
  16. use Symfony\Component\HttpFoundation\RedirectResponse;
  17. use Symfony\Component\Routing\Router;
  18. use Symfony\Contracts\Translation\TranslatorInterface;
  19. use Anyx\LoginGateBundle\Security\Events as LoginGateBundleEvents;
  20. /**
  21.  * Class LoginFailureHandler
  22.  * @package AWCmsBundle\Handler
  23.  *
  24.  */
  25. class LoginFailureHandler implements EventSubscriberInterface
  26. {
  27.     protected $session;
  28.     protected $translator;
  29.     
  30.     /**
  31.      * LoginFailureHandler constructor.
  32.      * @param SessionInterface $session
  33.      * @param TranslatorInterface $translator
  34.      */
  35.     public function __construct(SessionInterface $sessionTranslatorInterface $translator)
  36.     {
  37.         $this->session $session;
  38.         $this->translator $translator;
  39.     }
  40.     
  41.     public static function getSubscribedEvents()
  42.     {
  43.         return [
  44.             LoginGateBundleEvents::BRUTE_FORCE_ATTEMPT => ['onBruteForceAttempt']
  45.         ];
  46.     }
  47.     
  48.     public function onBruteForceAttempt(BruteForceAttemptEvent $event){
  49.         $this->session->getFlashBag()->add('notice_error'$this->translator->trans('user.form.too_many_attempts'));
  50.     }
  51. }