1

我有两个用户组。当我使用管理员用户登录时,它可以工作,但是当我尝试使用其他组的用户登录时,我得到一个无限循环。这是我正在使用的代码:

用户控制器.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');
}

谢谢

4

1 回答 1

1

我刚刚发现了问题。NonAdmins 用户根本不允许做任何事情,甚至不允许登录,因此他们被重定向到登录视图,从而创建了一个无限循环。

于 2013-06-20T10:15:08.957 回答