8000 Add tip for using new userIsGranted() function · symfony/symfony-docs@04a091b · GitHub
[go: up one dir, main page]

Skip to content

Commit 04a091b

Browse files
committed
Add tip for using new userIsGranted() function
1 parent 01afda2 commit 04a091b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

security.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2368,6 +2368,13 @@ want to include extra details only for users that have a ``ROLE_SALES_ADMIN`` ro
23682368
// ...
23692369
}
23702370
2371+
.. tip::
2372+
2373+
Using ``isGranted()`` checks authorization against the currently logged in user. If wanting to check
2374+
against a user that isn't logged in or if checking authorization when the user session is not
2375+
available (example: message queue, cronjob, command) ``userIsGranted()`` can be used to set the
2376+
user explicitly.
2377+
23712378
If you're using the :ref:`default services.yaml configuration <service-container-services-load-example>`,
23722379
Symfony will automatically pass the ``security.helper`` to your service
23732380
thanks to autowiring and the ``Security`` type-hint.

0 commit comments

Comments
 (0)
0