我需要在这里编辑loginredirect会话参数,以便它将重定向到不同的页面作为管理员或用户......事情是。索引硬编码,它将始终重定向到正常的用户索引视图忽略我的代码重定向管理员用户。我希望它这样,如果当前用户是管理员,它会重定向到admin_index代替cakephp auth loginRedirect
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'
)
)
)
);
用户控制器登录功能
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'));
}
}
首先检查用户登录,如果($这个 - > Auth->登录()){添加代码的REST} – Salines 2014-11-04 09:52:43
说行......现在我所有的登录始终重定向到登录页面,但是登录在页面顶部的链接现在注销*表示我的用户确实已登录* – 2014-11-04 09:59:08