Search code examples
symfonysymfony-security

Symfony does not fire security.login.failure event. Does not call listener function


Just as the title says. If i use

App\EventListener\AuthListener:

tags:
    - { name: 'kernel.event_listener', event: 'security.authentication.success', method: 'onLoginFailure' }

then the method gets called on successful login.

If I change the event to 'security.login.failure' (like it says in the documentation)

App\EventListener\AuthListener:

tags:
    - { name: 'kernel.event_listener', event: 'security.login.failure', method: 'onLoginFailure' }

, the event is never fired although the documentation says it should be fired every time a wrong password is entered.

https://symfony.com/doc/current/security.html#authentication-events

Symfony version 6.0, "symfony/security-bundle": "6.0.*",


Solution

  • Changing the tag 'security.login.failure' to full class name: 'Symfony\Component\Security\Http\Event\LoginFailureEvent' fixed the problem.