File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -77,6 +77,7 @@ edit a particular object. Here's an example implementation::
7777 // src/AppBundle/Security/Authorization/Voter/PostVoter.php
7878 namespace AppBundle\Security\Authorization\Voter;
7979
80+ use AppBundle\Entity\User;
8081 use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
8182 use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
8283 use Symfony\Component\Security\Core\User\UserInterface;
@@ -133,6 +134,13 @@ edit a particular object. Here's an example implementation::
133134 return VoterInterface::ACCESS_DENIED;
134135 }
135136
137+ // double-check that the User object is the expected entity.
138+ // It always will be, unless there is some misconfiguration of the
139+ // security system.
140+ if (!$user instanceof User) {
141+ throw new \LogicException('The user is somehow not our User class!');
142+ }
143+
136144 switch($attribute) {
137145 case self::VIEW:
138146 // the data object could have for example a method isPrivate()
You can’t perform that action at this time.
0 commit comments