Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

[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

Open
ker0x wants to merge1 commit intosymfony:6.2
base:6.2
Choose a base branch
Loading
fromker0x:feature/currentuser-attribute

Conversation

ker0x
Copy link
Contributor

Added an example to get the authenticated user with#[CurrentUser] attribute

@ker0xker0xforce-pushed thefeature/currentuser-attribute branch from9944c81 tobe4143cCompareMarch 6, 2023 10:08
@OskarStarkOskarStark requested a review fromwouterjMarch 7, 2023 05:14
): 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());
Copy link
Contributor

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
retrieve the authenticated user.
retrieve the authenticated user if any.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@94noni94noni94noni left review comments

@wouterjwouterjAwaiting requested review from wouterj

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@ker0x@94noni@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp