Using FOSUserBundle and Symfony2,
on my site, depending on the role of the user who is logged in, I want Logout to redirect alternatively to two different pages.
So, I want to do something like this:
{% if is_granted("ROLE_PREMIUM") %} <a href="{{ path('fos_user_security_logout_premium') }}">{{ 'layout.logout'|trans({}, 'FOSUserBundle') }}</a> {% else %} <a href="{{ path('fos_user_security_logout') }}">{{ 'layout.logout'|trans({}, 'FOSUserBundle') }}</a> {% endif %}
And then, somehow, do something like this:
<route id="fos_user_security_logout" pattern="/logout"> <default key="_controller">FOSUserBundle:Security:logout</default> </route> <route id="fos_seller_security_logout" pattern="/logoutPremium"> <default key="_controller">FOSUserBundle:Security:logoutPremium</default> </route>
But, since everything in logout is done in config.yml , config.yml all this configuration into the login and logout, I don’t know how to configure the second trigger and implement it. In fact, the only thing I want to do is redirect the user to two different pages according to the role. Everything else should remain unchanged.
All you need to do here in security.yml ?
logout: path: /logout target: /main/user
thanks a lot
source share