LoginFailureEvent.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Security\Http\Event;
  11. use Symfony\Component\HttpFoundation\Request;
  12. use Symfony\Component\HttpFoundation\Response;
  13. use Symfony\Component\Security\Core\Exception\AuthenticationException;
  14. use Symfony\Component\Security\Http\Authenticator\AuthenticatorInterface;
  15. use Symfony\Component\Security\Http\Authenticator\Passport\PassportInterface;
  16. use Symfony\Contracts\EventDispatcher\Event;
  17. /**
  18. * This event is dispatched after an error during authentication.
  19. *
  20. * Listeners to this event can change state based on authentication
  21. * failure (e.g. to implement login throttling).
  22. *
  23. * @author Wouter de Jong <wouter@wouterj.nl>
  24. */
  25. class LoginFailureEvent extends Event
  26. {
  27. private $exception;
  28. private $authenticator;
  29. private $request;
  30. private $response;
  31. private $firewallName;
  32. private $passport;
  33. public function __construct(AuthenticationException $exception, AuthenticatorInterface $authenticator, Request $request, ?Response $response, string $firewallName, ?PassportInterface $passport = null)
  34. {
  35. $this->exception = $exception;
  36. $this->authenticator = $authenticator;
  37. $this->request = $request;
  38. $this->response = $response;
  39. $this->firewallName = $firewallName;
  40. $this->passport = $passport;
  41. }
  42. public function getException(): AuthenticationException
  43. {
  44. return $this->exception;
  45. }
  46. public function getAuthenticator(): AuthenticatorInterface
  47. {
  48. return $this->authenticator;
  49. }
  50. public function getFirewallName(): string
  51. {
  52. return $this->firewallName;
  53. }
  54. public function getRequest(): Request
  55. {
  56. return $this->request;
  57. }
  58. public function setResponse(?Response $response)
  59. {
  60. $this->response = $response;
  61. }
  62. public function getResponse(): ?Response
  63. {
  64. return $this->response;
  65. }
  66. public function getPassport(): ?PassportInterface
  67. {
  68. return $this->passport;
  69. }
  70. }