hurin
hurin

Reputation: 63

Symfony 3.2.2 FOSUserBundle Authenticate user listener not trigger

I know this question has already been posted, and i did tried some if not all the answers I found, but without success yet, therefore here's my question:

I just installed a new Symfony application and successfully installed FOSUserBundle, made a few modification on the UserEntity, and on the FormRegistrationType (added some fields,...)

Then, I tried to follow this tutorial: http://symfony.com/doc/master/bundles/FOSUserBundle/controller_events.html

Here's my services.yml:

app.suscriber.authentification:
        class: MyBundle\Suscriber\AuthSubscriber
        arguments: [ "@doctrine" ]
        tags:
            - { name: kernel.event.suscriber }

And here's my AuthSuscriber class =>

<?php

namespace MyBundle\Suscriber;

use MyBundle\Entity\User;
use Doctrine\Bundle\DoctrineBundle\Registry;
use FOS\UserBundle\Event\FilterUserResponseEvent;
use FOS\UserBundle\Event\UserEvent;
use FOS\UserBundle\FOSUserEvents;
use FOS\UserBundle\Security\LoginManagerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;

class AuthSubscriber implements EventSubscriberInterface
{
    protected $doctrine;
    protected $user;

    public function __construct(Doctrine $doctrine)
    {
        $this->doctrine = $doctrine;
    }

    /**
     * {@inheritdoc}
     */
    public static function getSubscribedEvents()
    {
        return array(
            FOSUserEvents::REGISTRATION_COMPLETED => 'onRegistrationSuccess',
            FOSUserEvents::REGISTRATION_CONFIRMED => 'onRegistrationSuccess',
        );
    }

    public function onRegistrationSuccess(FilterUserResponseEvent $event, $eventName, EventDispatcherInterface $eventDispatcher)
    {
     dump('here, but not seen at any time');die();
     }
   }

I do see my service with the console:

php bin/console debug:container app.suscriber.authentification

output => enter image description here

But the following command line does not show my subscriber in any way =>

php bin/console debug:event-dispatcher | grep "fos_user.registration" -A10

With the following output =>

enter image description here

Even though it shows the AuthentificationListener from FOS\UserBundle...

If anyone could give me an hint on how to debug this kind of bug I would gladly listen to him, cause I'm completely lost here >____<"

Thanks,

Hurin

Upvotes: 1

Views: 320

Answers (1)

COil
COil

Reputation: 7596

Isn't there a typo in the tag name? Underscore _ instead of .

app.suscriber.authentification:
    class: MyBundle\Suscriber\AuthSubscriber
    arguments: [ "@doctrine" ]
    tags:
        - { name: kernel.event_subscriber }

The event list.

Upvotes: 1

Related Questions