Skip to content

Commit 0f7af22

Browse files
authored
document twig functions on impersonation
1 parent 40d7fbf commit 0f7af22

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

security/impersonating_user.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,18 @@ listener:
6262
;
6363
};
6464
65-
To switch to another user, add a query string with the ``_switch_user``
65+
To switch to another user, leverage the add a query string with the ``_switch_user``
6666
parameter and the username (or whatever field our user provider uses to load users)
6767
as the value to the current URL:
6868

6969
.. code-block:: text
7070
7171
http://example.com/somewhere?_switch_user=thomas
7272
73+
.. tip::
74+
75+
You can leverage the Twig function ``impersonation_path('thomas')``
76+
7377
.. tip::
7478

7579
Instead of adding a ``_switch_user`` query string parameter, you can pass
@@ -128,6 +132,10 @@ To switch back to the original user, use the special ``_exit`` username:
128132
129133
http://example.com/somewhere?_switch_user=_exit
130134
135+
.. tip::
136+
137+
You can leverage the Twig function ``impersonation_exit_path('/somewhere')``
138+
131139
This feature is only available to users with a special role called ``ROLE_ALLOWED_TO_SWITCH``.
132140
Using :ref:`role_hierarchy <security-role-hierarchy>` is a great way to give this
133141
role to the users that need it.

0 commit comments

Comments
 (0)