Skip to content

Commit

Permalink
Cleaning up the code in auth example
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Dec 8, 2011
1 parent b43c12d commit ddc9e42
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions en/tutorials-and-examples/blog-auth-example/auth.rst
Original file line number Diff line number Diff line change
Expand Up @@ -338,19 +338,15 @@ and add the following content::
// app/Controller/PostsController.php

public function isAuthorized($user) {
if (parent::isAuthorized($user)) {
if ($this->action === 'add') {
// All registered users can add posts
return true;
} else {
if ($this->action === 'add') {
// All registered users can add posts
return true;
}
if (in_array($this->action, array('edit', 'delete'))) {
$postId = $this->request->params['pass'][0];
return $this->Post->isOwnedBy($postId, $user['id']);
}
return false;
}
if (in_array($this->action, array('edit', 'delete'))) {
$postId = $this->request->params['pass'][0];
return $this->Post->isOwnedBy($postId, $user['id']);
}
return parent::isAuthorized();
}

We're now overriding the AppController's ``isAuthorized()`` call and internally
Expand Down

0 comments on commit ddc9e42

Please sign in to comment.