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 @@ -62,6 +62,7 @@ edit a particular object. Here's an example implementation::
62
62
use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
63
63
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
64
64
use Symfony\Component\Security\Core\User\UserInterface;
65
+ use AppBundle\Entity\User;
65
66
66
67
class PostVoter implements VoterInterface
67
68
{
@@ -118,6 +119,13 @@ edit a particular object. Here's an example implementation::
118
119
return VoterInterface::ACCESS_DENIED;
119
120
}
120
121
122
+ // double-check that our User object is the entity we expect.
123
+ // It always will be, unless we've configured our security system
124
+ // in some other way.
125
+ if (!$user instanceof User) {
126
+ throw new \LogicException('The user is somehow not our User class!');
127
+ }
128
+
121
129
switch($attribute) {
122
130
case self::VIEW:
123
131
// the data object could have for example a method isPrivate()
You can’t perform that action at this time.
0 commit comments