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.

2 Answers 2

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}}" />
Sign up to request clarification or add additional context in comments.

2 Comments

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?
@Axxis You can create your form. Read Security part in documentation.
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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.