4
votes

I'm developing an application with Symfony2 and FOSUserbundle.

When a user logs in on the system I want to redirect them to /user/username, were username obviously change with every user.

One option of Security.yml is default_target_path. Is it possible to set default_target_path to a dynamic path or I need to override the class of FOSUB on charge of login.

2

2 Answers

1
votes

Overwrite SecuredController and Templemate. In controller when user is login, create variable and pass it to your templemate

<input type="hidden" name="_target_path" value="{{redirect_url}}" />
1
votes

The answer above is wrong, you have to register a service as the success_handler for your firewall implementing AuthenticationSuccessHandlerInterface (you can mimic DefaultAuthenticationSuccessHandler)

right answer here: Symfony2 extending DefaultAuthenticationSuccessHandler