File tree 2 files changed +8
-3
lines changed
2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -2726,7 +2726,7 @@ anonymous users access by checking if there is no user set on the token::
2726
2726
.. versionadded :: 7.3
2727
2727
2728
2728
The vote parameter in the :method: `Symfony\\ Component\\ Security\\ Core\\ Authorization\\ Voter\\ VoterInterface::voteOnAttribute ` method
2729
- voteOnAttribute method was introduced in Symfony 7.3.
2729
+ was introduced in Symfony 7.3.
2730
2730
2731
2731
Setting Individual User Permissions
2732
2732
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ which makes creating a voter even easier::
52
52
.. versionadded :: 7.3
53
53
54
54
The vote parameter in the :method: `Symfony\\ Component\\ Security\\ Core\\ Authorization\\ Voter\\ VoterInterface::voteOnAttribute ` method
55
- voteOnAttribute method was introduced in Symfony 7.3.
55
+ was introduced in Symfony 7.3.
56
56
57
57
.. _how-to-use-the-voter-in-a-controller :
58
58
@@ -206,7 +206,12 @@ would look like this::
206
206
private function canEdit(Post $post, User $user): bool
207
207
{
208
208
// this assumes that the Post object has a `getOwner()` method
209
- return $user === $post->getOwner();
209
+ if ($user === $post->getOwner()) {
210
+ return true;
211
+ }
212
+
213
+ $vote->reasons[] = 'You are not the owner of the Post.';
214
+ return false;
210
215
}
211
216
}
212
217
You can’t perform that action at this time.
0 commit comments