Skip to content

Commit

Permalink
minor #5476 [Cookbook][Security] some additional tweaks for the voter…
Browse files Browse the repository at this point in the history
… cookbook (xabbuh)

This PR was merged into the 2.6 branch.

Discussion
----------

[Cookbook][Security] some additional tweaks for the voter cookbook

| Q             | A
| ------------- | ---
| Doc fix?      | yes
| New docs?     | no
| Applies to    | 2.6+
| Fixed tickets |

This applies the comments left by @wouterj in e46f02e.

Commits
-------

10e022d some additional tweaks for the voter cookbook
  • Loading branch information
weaverryan committed Jul 25, 2015
2 parents e93c251 + 10e022d commit 2874a67
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions cookbook/security/voters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ edit a particular object. Here's an example implementation:
break;
case self::EDIT:
// we assume that our data object has a method getOwner() to
// get the current owner user entity for this data object
// this assumes that the data object has a getOwner() method
// to get the entity of the user who owns this data object
if ($user->getId() === $post->getOwner()->getId()) {
return true;
}
Expand Down Expand Up @@ -218,9 +218,7 @@ from the authorization checker is called.
$authChecker = $this->get('security.authorization_checker');
if (false === $authChecker->isGranted('view', $post)) {
throw $this->createAccessDeniedException('Unauthorized access!');
}
$this->denyAccessUnlessGranted('view', $post, 'Unauthorized access!');
return new Response('<h1>'.$post->getName().'</h1>');
}
Expand Down

0 comments on commit 2874a67

Please sign in to comment.