You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When updating the docs, I didn't quite take the workings of the security into account. The following example is broken:
useSymfony\Component\Security\Core\User\UserInterface;
publicfunctionindexAction(UserInterface$user)
{
if (!$this->get('security.authorization_checker')->isGranted('IS_AUTHENTICATED_FULLY')) {
throw$this->createAccessDeniedException();
}
// the above is a shortcut for this$user = $this->get('security.token_storage')->getToken()->getUser();
}
This will lead to an error unless access_control has already triggered the authentication process to get a user object. The example can be fixed in two ways:
Add an access_control example that triggers security here which populates the object
Add @Security("is_granted('IS_AUTHENTICATED_FULLY')") to trigger security before the $user is required
Besides of this, there's a small other issue: // the above is a shortcut for this makes it look like the isGranted is part of the "shortcut", while it's only the type-hint of the method that is part of the shortcut.
The text was updated successfully, but these errors were encountered:
@javiereguiluz as it's already explained below, I think the 2 comments in the code example can be removed (if that's what you're aiming at). 👍 for checking this, I already forgot about this issue
This PR was squashed before being merged into the 3.3 branch (closes#9060).
Discussion
----------
Don't mention the UserInterface type-hinting
This fixes#7506. Ping @iltar.
Commits
-------
3347569 Don't mention the UserInterface type-hinting
http://symfony.com/doc/current/security.html#retrieving-the-user-object
When updating the docs, I didn't quite take the workings of the security into account. The following example is broken:
This will lead to an error unless
access_control
has already triggered the authentication process to get a user object. The example can be fixed in two ways:access_control
example that triggers security here which populates the object@Security("is_granted('IS_AUTHENTICATED_FULLY')")
to trigger security before the$user
is requiredBesides of this, there's a small other issue:
// the above is a shortcut for this
makes it look like theisGranted
is part of the "shortcut", while it's only the type-hint of the method that is part of the shortcut.The text was updated successfully, but these errors were encountered: