I tryed for 3 days to make a redirection in FOSUser to redirect logged people to index if they try to access the login page, but unfortunately it's seems that there are no way to do this.
How can I do this ?
I tryed for 3 days to make a redirection in FOSUser to redirect logged people to index if they try to access the login page, but unfortunately it's seems that there are no way to do this.
How can I do this ?
This little extension in the loginAction should do the trick..
$user = $this->container->get('security.context')->getToken()->getUser()
if (is_object($user) && $user instanceof UserInterface) {
return new RedirectResponse($this->container->get('router')->generate('_your_route'));
}
You can override FOSUserBundle SecurityController loginAction() method. Inside, check if the user is connected with $this->container->get('security.context')->getToken()->getUser(); and redirect with $this->redirect if needed.
This can be done with default_target_path in firewall configuration:
security:
firewalls:
somename:
form_login:
default_target_path: /your-desired-path
Find the official description in the book: http://symfony.com/doc/current/reference/configuration/security.html#form-login-configuration