I need to edit the loginredirect session parameter here so that it will redirect to different page as an admin or user... thing is. with index hard coded in, it will always redirect to the normal user index view ignoring my code to redirect admin users . I want it so that if the current user is an admin, it will redirect to admin_index instead
appControler
public $components = array(
'Session',
'Auth' => array(
'loginRedirect' => array(
'controller' => 'users',
'action' => 'index'
),
'logoutRedirect' => array(
'controller' => 'users',
'action' => 'login'
),
'authenticate' => array(
'Form' => array(
'passwordHasher' => 'Blowfish'
)
)
)
);
user controller login function
public function login() {
if($this->Auth->user('account_type')=='admin'){
return $this->Auth->loginRedirect = array('controller' => 'users',
'action' => 'admin_index');
}
elseif($this->Auth->user('account_type')=='user'){
return $this->Auth->loginRedirect = array('controller' => 'users',
'action' => 'view');
}
else {
if ($this->Auth->login()) {
return $this->redirect($this->Auth->redirect());
}
$this->Session->setFlash(__('Invalid username or password, try again'));
}
}