
Untitled
By: a guest on
May 7th, 2012 | syntax:
None | size: 1.16 KB | hits: 12 | expires: Never
class AppController extends Controller {
public $components = array(
'Session',
'Auth' => array(
'loginRedirect' => array('controller' => '/', 'action' => '/'),
'logoutRedirect' => array('controller' => 'users', 'action' => 'login'),
'authError' => "You can't access that page",
'authorize' => array('Controller')
)
);
public function isAuthorized($user) {
// let everyone onto the pages
if ($this->request['controller'] == "pages") return true;
// if the user is an admin, they can do all.
if($this->Auth->user('group') == 'admin') return true;
if(!empty($this->permissions[$this->action])){
if($this->permissions[$this->action] == '*') return true;
if(in_array($this->Auth->user('group'), $this->permissions[$this->action])) return true;
}
return false;
}
public function beforeFilter() {
$this->Auth->allow('index', 'view', 'denied', 'archive');
$this->set('logged_in', $this->Auth->loggedIn());
$this->set('current_user', $this->Auth->user());
}
}