This is the how to for redirection implementation by roles after login or logout in Symfony2
- Copy
AfterLoginRedirection.php
andAfterLogoutRedirection.php
to your bundle under the "Redirection" directory - Edit your
services.yml
file in your bundle and copy/paste the content ofservices.yml
- Edit your
security.yml
file... - ... add
success_handler: redirect.after.login
inform_login:
section - ... add
success_handler: redirect.after.logout
inlogout:
section
For more informations, you can read my explanation on my blog (in french only)
I still don't understand how if one user has many roles but each role has only one redirect link, where the user will be redirected after login? Do symfony allow many to one relationship user to the role than many to many?