Skip to content

Document twig functions on impersonation #19098

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions security/impersonating_user.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ as the value to the current URL:

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

.. tip::

You can leverage the Twig function ``impersonation_path('thomas')``

.. versionadded:: 6.4

The ``impersonation_path()`` function was introduced in Symfony 6.4.

.. tip::

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

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

.. tip::

You can leverage the Twig function ``impersonation_exit_path('/somewhere')``

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets add the versionadded here too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure, as far as I know and can find on GitHub, impersonation_exit_path was added in v5

This feature is only available to users with a special role called ``ROLE_ALLOWED_TO_SWITCH``.
Using :ref:`role_hierarchy <security-role-hierarchy>` is a great way to give this
role to the users that need it.
Expand Down