You can find the events that FOSUserBundle fires in the FOSUserEvents class . In particular, this is the one you are looking for:
const SECURITY_IMPLICIT_LOGIN = 'fos_user.security.implicit_login';
The documentation for connecting to these events can be found on the Join the controller pages page. "In your case, you need to implement something like this:
namespace Acme\UserBundle\EventListener; use FOS\UserBundle\FOSUserEvents; use FOS\UserBundle\Event\FormEvent; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\Security\Http\SecurityEvents; use Symfony\Component\Security\Http\Event\InteractiveLoginEvent; class LoginListener implements EventSubscriberInterface { private $container; public function __construct($container) { $this->container = $container; } public static function getSubscribedEvents() { return array( FOSUserEvents::SECURITY_IMPLICIT_LOGIN => 'onLogin', SecurityEvents::INTERACTIVE_LOGIN => 'onLogin', ); } public function onLogin($event) {
Then you must identify the listener as a service and enter the container. Alternatively, you can enter only the service that you need, and not the entire container.
services: acme_user.login: class: Acme\UserBundle\EventListener\LoginListener arguments: [@container] tags: - { name: kernel.event_subscriber }
There is also another method that involves overriding the controller , but, as indicated in the documentation, you need to duplicate their code so that it is not cleaned up exactly and is tied to a break if (or, rather, when) the FOSUserBundle changes.
source share