0

One simple question please.

I have a service that it's launched onKernelRequest, but it doesn't work when an user is loggin in my app.

It's possible setup a service that it will be launched on login action?

This is my actual service:

cc.database_switcher:
    class:      XXXXX\EventListener\DatabaseSwitcherEventListener
    arguments:  [@request, @doctrine.dbal.default_connection, @logger]
    scope:      request
    tags:
        - { name: kernel.event_listener, event: kernel.request, method: onKernelRequest }

This service don't work con loggin action.

Karmo
  • 383
  • 1
  • 3
  • 13
  • You can check that http://stackoverflow.com/a/11180531/1203821 – Mert Öksüz Jan 11 '17 at 12:10
  • 1
    Possible duplicate of [Symfony2: After successful login event, perform set of actions](http://stackoverflow.com/questions/11180351/symfony2-after-successful-login-event-perform-set-of-actions) – t-n-y Jan 11 '17 at 12:51

1 Answers1

0

Create your own class that implements Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface and declare it as service. Implement all the logic you want in onAuthenticationSuccess method. Then define success_handler option in your security.yml in form_login area:

form_login:
    ...
    ...
    success_handler: your_own_on_success_login_handler

An example

E.K.
  • 1,045
  • 6
  • 10