1
votes

I would like to redirect the user successfully logged on two specific pages and only based on roles. User on /client and Admin on /admin. I'm using FOSUserBundle 2.1 and Symfony 4.

I don't know what event to use to be able to catch the token and to give a Response redirection.

With security.authentication.success or security.interactive_login i can't give a event response to redirect the user.

1
You can set two providers, two firewalls and access control for client and admin - Pec

1 Answers

0
votes

i managed to do that kind of thing (in symfony 2.8 fosuser 2.0) using security.interactive_login event and use a simple header('Location: ...) ; exit(); inside

To get user in interactive_login callback you can use :

$user = $event->getAuthenticationToken()->getUser();

hope this can help...