Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 04a091b

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

File tree

1 file changed

+7
-0
lines changed
Filter options

1 file changed

+7
-0
lines changed

‎security.rst

Copy file name to clipboardExpand all lines: security.rst
+7Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.