| Total Complexity | 5 |
| Total Lines | 28 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | class SecuritySubscriber implements EventSubscriberInterface |
||
| 12 | { |
||
| 13 | public static function getSubscribedEvents() |
||
| 14 | { |
||
| 15 | return array( |
||
| 16 | AuthenticationEvents::AUTHENTICATION_FAILURE => 'onAuthenticationFailure', |
||
| 17 | AuthenticationEvents::AUTHENTICATION_SUCCESS => 'onAuthenticationSuccess', |
||
| 18 | ); |
||
| 19 | } |
||
| 20 | |||
| 21 | public function __construct(LoggerInterface $logger) |
||
| 22 | { |
||
| 23 | $this->logger = $logger; |
||
|
|
|||
| 24 | } |
||
| 25 | |||
| 26 | public function onAuthenticationFailure(AuthenticationFailureEvent $event) |
||
| 27 | { |
||
| 28 | $exception = $event->getAuthenticationException(); |
||
| 29 | $token = $event->getAuthenticationToken(); |
||
| 30 | $creds = $token->getCredentials(); |
||
| 31 | $this->logger->error("Login failed for " . $creds['username'] . ": " . $exception->getMessage()); |
||
| 32 | } |
||
| 33 | |||
| 34 | public function onAuthenticationSuccess(AuthenticationEvent $event) |
||
| 39 | } |
||
| 40 | } |
||
| 41 | } |
||
| 42 |