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