Skip to content

Commit

Permalink
Add code to stop user edit/delete other users' information.
Browse files Browse the repository at this point in the history
  • Loading branch information
stinkinkevin committed Nov 5, 2015
1 parent 52d82a6 commit 06e5a52
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/Controller/UsersController.php
Expand Up @@ -8,6 +8,15 @@ public function beforeFilter() {
$this->Auth->allow('add');
}

public function isAuthorized($user){
if (in_array($this->action, array('edit', 'delete'))) {
if ($user['id'] != $this->request->params['pass'][0]) {
return false;
}
}
return true;
}

public function login() {
// check the request type to see if it's a post request
// if it is, that means someone is trying to login and submit the form
Expand Down
1 change: 1 addition & 0 deletions app/View/Layouts/default.ctp
Expand Up @@ -49,6 +49,7 @@ $cakeDescription = __d('cake_dev', 'CakePHP: the rapid development php framework
<?php endif; ?>
</div>
<?php echo $this->Session->flash(); ?>
<?php echo $this->Session->flash('auth'); ?>

<?php echo $content_for_layout; ?>

Expand Down

0 comments on commit 06e5a52

Please sign in to comment.