Skip to content

Commit 0d1e3dc

Browse files
committed
minor #19098 Document twig functions on impersonation (94noni)
This PR was squashed before being merged into the 6.4 branch. Discussion ---------- Document twig functions on impersonation i am updating one of my app to 6.4 and also reading some https://symfony.com/blog/category/living-on-the-edge/7.0-6.4 found this was not yet documented from https://symfony.com/blog/new-in-symfony-6-4-impersonation-utilities edit: following code PR comment on Symfony-docs repo, found #18966 to me this is uselefull here as well as more "usage dev doc" instead of "TOC doc", wdyt? FYO when googling "symfony user switch" the first link is the page I am proposing to edit thx Commits ------- 5c04c6b Document twig functions on impersonation
2 parents 53d1659 + 5c04c6b commit 0d1e3dc

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

security/impersonating_user.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@ as the value to the current URL:
7070

7171
http://example.com/somewhere?_switch_user=thomas
7272

73+
.. tip::
74+
75+
You can leverage the Twig function ``impersonation_path('thomas')``
76+
77+
.. versionadded:: 6.4
78+
79+
The ``impersonation_path()`` function was introduced in Symfony 6.4.
80+
7381
.. tip::
7482

7583
Instead of adding a ``_switch_user`` query string parameter, you can pass
@@ -128,6 +136,10 @@ To switch back to the original user, use the special ``_exit`` username:
128136

129137
http://example.com/somewhere?_switch_user=_exit
130138

139+
.. tip::
140+
141+
You can leverage the Twig function ``impersonation_exit_path('/somewhere')``
142+
131143
This feature is only available to users with a special role called ``ROLE_ALLOWED_TO_SWITCH``.
132144
Using :ref:`role_hierarchy <security-role-hierarchy>` is a great way to give this
133145
role to the users that need it.

0 commit comments

Comments
 (0)