code_junkie

CakePHP 1.2: How do I lock a given controller from access from anyone but admins?

Nov 12th, 2011
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. if (isset($this->params[Configure::read('Routing.admin')])) { //User is trying to access a page using the admin route
  2. if ($this->Session->check('someSessionVariable')) { //Check user has some session variable set.
  3. // User is accessing an admin page and has permission, do something, or in most cases do nothing.
  4. } else { //No sessions set for user, redirect to login page.
  5. $this->redirect('/yourLoginPage'); //Redirect
  6. }
  7. }
Add Comment
Please, Sign In to add comment