Skip to content

Improve code example for the custom User Provider #10064

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

pwbzh
Copy link

@pwbzh pwbzh commented Jul 13, 2018

Hello,

The example code in the documentation "How to Create a custom User Provider" call twice the "loadUserByUsername" method.

Thanks.

@@ -158,7 +158,7 @@ Here's an example of how this might look::
);
}

return $this->loadUserByUsername($user->getUsername());
Copy link
Member

Choose a reason for hiding this comment

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

The point here is that we want to refresh the user. Thus, we must call the webservice for the currently logged in user. We could write the same logic from loadUserByUsername() here again. But the example prefers to not duplicate the logic and just use the existing implementation. So, technically the code was already correct. But maybe we could improve the readability by extracting the common code into a private method which we would then use in both loadUserByUsername() and refreshUser().

@javiereguiluz
Copy link
Member

@pweyl thanks a lot for your contribution! As @xabbuh said, this should be solved differently (and that's why we've created #10066 to replace this pull request). In any case, we appreciate your contribution because thanks to it we realized about this doc issue. Thanks a lot and we're looking forward to receive more contributions from you in the future!

javiereguiluz added a commit that referenced this pull request Jul 14, 2018
…derstand (javiereguiluz)

This PR was merged into the 2.8 branch.

Discussion
----------

Refactor a security code example to make it easier to understand

This replaces #10064 and extracts the common code into a new method.

Commits
-------

e588401 Refactor a security code example to make it easier to understand
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants