File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -1644,6 +1644,24 @@ To switch back to the original user, use the special ``_exit`` username:
1644
1644
1645
1645
http://example.com/somewhere?_switch_user=_exit
1646
1646
1647
+ During impersonation the user is provided with a special role called
1648
+ ``ROLE_PREVIOUS_ADMIN ``. In a template, for instance, this role can decide
1649
+ if a link to exit impersonation needs to be shown:
1650
+
1651
+ .. configuration-block ::
1652
+
1653
+ .. code-block :: html+jinja
1654
+
1655
+ {% if is_granted('ROLE_PREVIOUS_ADMIN') %}
1656
+ <a href="{{ path('homepage', {_switch_user: '_exit'}) }}">Exit impersonation</a>
1657
+ {% endif %}
1658
+
1659
+ .. code-block :: html+php
1660
+
1661
+ <?php if ($view['security']->isGranted('ROLE_PREVIOUS_ADMIN')): ?>
1662
+ <a href="<?php echo $view['router']->generate('homepage', array('_switch_user' => '_exit') ?>">Exit impersonation</a>
1663
+ <?php endif; ?>
1664
+
1647
1665
Of course, this feature needs to be made available to a small group of users.
1648
1666
By default, access is restricted to users having the ``ROLE_ALLOWED_TO_SWITCH ``
1649
1667
role. The name of this role can be modified via the ``role `` setting. For
You can’t perform that action at this time.
0 commit comments