8000 [Cookbook][Security] some additional tweaks for the voter cookbook by xabbuh · Pull Request #5476 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content
8000

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 25, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
some additional tweaks for the voter cookbook
  • Loading branch information
xabbuh committed Jul 23, 2015
commit 10e022d0a2b4558d62e8cdb3f7e3608581ed6e54
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 @@ -214,9 +214,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