Pierre de LESPINAY
Pierre de LESPINAY

Reputation: 46188

Symfony2 - FOS UserBundle - Original request redirection

I'm using FOS UserBundle and I have defined a custom AuthenticationSuccessHandler to show a different home page depending on the roles, but I think it should be called only if the user originally requested the login page, shouldn't it ?

On login success I'd like to be redirected to the original request.

As described in the docs, it seems to be the default behavior, but in my case, it still uses my authentication handler.

Can someone help me to redirect the user to his original request ?


For the record, here is how I registered my authentication success handler service:

services:
    security.success_handler:
        class:  Glide\SecurityBundle\[...]\AuthenticationSuccessHandler
        public: false
        arguments: ['@router', '@security.context']

Upvotes: 0

Views: 555

Answers (1)

MrGlass
MrGlass

Reputation: 9262

Yes, the default behavior is to redirect the user to the page they originally requested. However, since you are overriding the default authentication handler, you need to handle redirecting them to that page yourself.

I recommend you look at symfonys authentication handler and mimic its process for figuring out the users original request.

Upvotes: 2

Related Questions