我有两个用户组。当我使用管理员用户登录时,它可以工作,但是当我尝试使用其他组的用户登录时,我得到一个无限循环。这是我正在使用的代码:
用户控制器.php:
public function login() {
if ($this->Session->read('Auth.User')) {
$this->Session->setFlash('You are logged in!');
$this->redirect('/pwds', null, false);
}
else
if ($this->request->is('post')) {
if ($this->Auth->login()) {
$this->redirect($this->Auth->redirect());
} else {
$this->Session->setFlash('Your username or password was incorrect.');
}
}
}
public function logout() {
$this->Session->setFlash('Good-Bye');
$this->redirect($this->Auth->logout());
}
public function beforeFilter() {
parent::beforeFilter();
//$this->Auth->allow('index', 'view');
}
应用控制器.php:
public function beforeFilter() {
//Configure AuthComponent
$this->Auth->allow('display');
$this->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
$this->Auth->logoutRedirect = array('controller' => 'users', 'action' => 'login');
$this->Auth->loginRedirect = array('controller' => 'pwds', 'action' => 'index');
}
谢谢