Skip to content

Commit 77e92fe

Browse files
Check for is granted impersonator on Symfony >= 5.4 (#1627)
1 parent 7dbd45b commit 77e92fe

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Resources/views/Admin/Core/user_block.html.twig

+5-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ file that was distributed with this source code.
1515
{% set _logout_uri = url('sonata_user_admin_security_logout') %}
1616
{% set _logout_text = 'user_block_logout'|trans({}, 'SonataUserBundle') %}
1717

18-
{% if is_granted('ROLE_PREVIOUS_ADMIN') and sonata_user.isImpersonatingEnabled %}
18+
{# TODO: Remove the check for the IS_IMPERSONATOR constant when dropping support for Symfony 4.4 #}
19+
{% if sonata_user.isImpersonatingEnabled and (constant('Symfony\\Component\\Security\\Core\\Authorization\\Voter\\AuthenticatedVoter::IS_IMPERSONATOR') is defined ?
20+
is_granted('IS_IMPERSONATOR') :
21+
is_granted('ROLE_PREVIOUS_ADMIN'))
22+
%}
1923
{% set _bg_class = 'bg-light-green' %}
2024
{% set _logout_uri = url(sonata_user.impersonatingRoute, sonata_user.impersonatingRouteParameters|merge({'_switch_user': '_exit'})) %}
2125
{% set _logout_text = 'switch_user_exit'|trans({}, 'SonataUserBundle') %}

0 commit comments

Comments
 (0)