4

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.

Axxiss
  • 4,759
  • 4
  • 26
  • 45

2 Answers2

1

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

Community
  • 1
  • 1
ROLO
  • 581
  • 4
  • 13
1

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}}" />
rtyshyk
  • 942
  • 1
  • 15
  • 29
  • Ok, I trying to do ti that way. But as I'm quite new to PHP I'm a little bit stuck. Is there a proper way to modify the Login form or should I copy & paste FOSUB's login form and add the hidden input inside the form? – Axxiss Feb 12 '12 at 21:30
  • @Axxis You can create your form. Read Security part in documentation. – rtyshyk Feb 14 '12 at 10:39