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::
77
77
// src/AppBundle/Security/Authorization/Voter/PostVoter.php
78
78
namespace AppBundle\Security\Authorization\Voter;
79
79
80
+ use AppBundle\Entity\User;
80
81
use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
81
82
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
82
83
use Symfony\Component\Security\Core\User\UserInterface;
@@ -133,6 +134,13 @@ edit a particular object. Here's an example implementation::
133
134
return VoterInterface::ACCESS_DENIED;
134
135
}
135
136
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
+
136
144
switch($attribute) {
137
145
case self::VIEW:
138
146
// the data object could have for example a method isPrivate()
You can’t perform that action at this time.
0 commit comments