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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With