Skip to content

Commit 7815041

Browse files
committed
Add tip for using new userIsGranted() function
1 parent d5c0003 commit 7815041

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

security.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2431,6 +2431,18 @@ want to include extra details only for users that have a ``ROLE_SALES_ADMIN`` ro
24312431
// ...
24322432
}
24332433
2434+
.. tip::
2435+
2436+
Using ``isGranted()`` checks authorization against the currently logged in user. If you need to check
2437+
against a user that is not the one logged in or if checking authorization when the user session is not
2438+
available in a CLI context (example: message queue, cronjob) ``userIsGranted()`` can be used to set the
2439+
target user explicitly.
2440+
2441+
.. versionadded:: 6.4
2442+
2443+
The :method:`Symfony\\Bundle\\SecurityBundle\\Security::userIsGranted`
2444+
method was introduced in Symfony 6.4.
2445+
24342446
If you're using the :ref:`default services.yaml configuration <service-container-services-load-example>`,
24352447
Symfony will automatically pass the ``security.helper`` to your service
24362448
thanks to autowiring and the ``Security`` type-hint.

0 commit comments

Comments
 (0)