Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which is the best method to redirect after login in FOSUserBundle

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

like image 841
Sethunath K M Avatar asked Oct 08 '22 15:10

Sethunath K M


1 Answers

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.

like image 148
Mun Mun Das Avatar answered Oct 12 '22 23:10

Mun Mun Das