Skip to content

Commit bdd20d3

Browse files
HeahDudejaviereguiluz
authored andcommitted
Fixed security expression testing user
1 parent 4e01746 commit bdd20d3

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

security.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -964,15 +964,15 @@ You can also use expressions inside your templates:
964964
.. code-block:: html+jinja
965965

966966
{% if is_granted(expression(
967-
'"ROLE_ADMIN" in roles or (user and user.isSuperAdmin())'
967+
'"ROLE_ADMIN" in roles or (not is_anonymous() and user.isSuperAdmin())'
968968
)) %}
969969
<a href="...">Delete</a>
970970
{% endif %}
971971

972972
.. code-block:: html+php
973973

974974
<?php if ($view['security']->isGranted(new Expression(
975-
'"ROLE_ADMIN" in roles or (user and user.isSuperAdmin())'
975+
'"ROLE_ADMIN" in roles or (not is_anonymous() and user.isSuperAdmin())'
976976
))): ?>
977977
<a href="...">Delete</a>
978978
<?php endif; ?>

security/expressions.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ accepts an :class:`Symfony\\Component\\ExpressionLanguage\\Expression` object::
1818
public function indexAction()
1919
{
2020
$this->denyAccessUnlessGranted(new Expression(
21-
'"ROLE_ADMIN" in roles or (user and user.isSuperAdmin())'
21+
'"ROLE_ADMIN" in roles or (not is_anonymous() and user.isSuperAdmin())'
2222
));
2323

2424
// ...

0 commit comments

Comments
 (0)