我有两组用户。当我使用管理员用户登录时,它可以正常工作,但是当我尝试使用其他组中的用户登录时,我得到了无限循环。 这是我正在使用的代码:
UsersController.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');
}
AppController.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');
}
谢谢
答案 0 :(得分:1)
我刚发现了这个问题。 NonAdmins用户根本不允许做任何事情,甚至不允许登录,因此他们被重定向到登录视图,创建了无限循环。