Which is the best method to redirect after login in FOSUserBundle
-
27-10-2019 - |
Question
Which is the best method to implement role based redirect after login in FOSUserBundle ?
Should I use a success handler and write the redirection logic in onAuthenticationSuccess
or Should I use a security listener and write the redirection logic in onSecurityInteractiveLogin
Solution
I think security listeners are used by other bundles to do some post-login operations like table update, setting cookie etc. While same can be done by success_handler, it is called once for each firewall configuration in app/config/security.yml. So you have full control over it. So I think it is better to implement redirection logic in onAuthenticationSuccess method of your success_handler service class.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow