In my cake 2.2 app I have the following beforeFilter() set up in my App Controller:
public function beforeFilter() {
//Configure AuthComponent
// Admin
if($this->Auth->user('group_id') == '12') {
$this->Auth->allow('admin_index');
$this->Auth->loginAction = array('controller' => 'users', 'action' => 'login', 'admin' => FALSE);
$this->Auth->loginRedirect = array('controller' => 'pages', 'action' => 'index', 'admin' => TRUE);
$this->Auth->logoutRedirect = array('controller' => 'users', 'action' => 'login', 'admin' => FALSE);
$this->set("group", "admin");
// Staff
}
if($this->Auth->user('group_id') == '13') {
$this->Auth->allow('admin_index');
$this->Auth->loginAction = array('controller' => 'users', 'action' => 'login', 'admin' => FALSE);
$this->Auth->loginRedirect = array('controller' => 'pages', 'action' => 'index', 'admin' => TRUE);
$this->Auth->logoutRedirect = array('controller' => 'users', 'action' => 'login', 'admin' => FALSE);
$this->set("group", "staff");
So basically I want all users regardles of user group to be sent to /users/login when the session expires. This works for users but any admin users get redirected to admin/users/login and presented with a Missing method in users controller error (because this isnt an admin method). For some reason the 'admin' => FALSE isnt working.
So, how can I get all users regardless of user type to get redirected to the NON admin method/url of /users/login
// Users
}
if($this->Auth->user('group_id') == '14') {
$this->Auth->allow(array('controller' => 'pages', 'action' => 'index', 'admin' => FALSE));
$this->Auth->loginAction = array('controller' => 'users', 'action' => 'login', 'admin' => FALSE);
$this->Auth->loginRedirect = array('controller' => 'pages', 'action' => 'index', 'admin' => FALSE);
$this->Auth->logoutRedirect = array('controller' => 'users', 'action' => 'login', 'admin' => FALSE);
$this->set("group", "user");
}
// General logout redirect (including expired session redirect)
$this->Auth->logoutRedirect = array('controller' => 'users', 'action' => 'login', 'admin' => FALSE);
}