Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork5.2k
[Security] Add example to fetch User with CurrentUser attribute#18005
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:6.2
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
9944c81
tobe4143c
Compare): Response { | ||
// Call whatever methods you've added to your User class | ||
// For example, if you added a getFirstName() method, you can use that. | ||
return new Response('Well hi there '.$user->getFirstName()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
what if $user result in being null like if someone remove the isgranted above
better force it to not null
and perhaps add other example with current user that may be null?
.. note:: | ||
The ``#[CurrentUser]`` attribute can only be used in controller arguments to | ||
retrieve the authenticated user. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
retrieve the authenticated user. | |
retrieve the authenticated user if any. |
Added an example to get the authenticated user with
#[CurrentUser]
attribute