我找不到我的问题的解决方案。我有一个使用 Auth 组件和 ACL 组件的 CakePHP 网站。我不希望不活跃的用户能够登录。
我发现 Auth 组件中的 userScope 可以做到这一点。因此,在beforeFilter内的AppController中,我添加了以下内容:
$this->Auth->userScope = array('User.active' => 1);
当然,在我的 UserController beforeFilter 中,调用了父方法。
但是,这无济于事,我仍然可以使用活动设置为 0 的用户登录。我认为这可能是因为 ACL 组件?
这是我在 AppController 中的 beforFilter
public function beforeFilter()
{
if (!$this->Session->check('Auth.User'))
$this->layout = 'identification';
$this->Auth->allow('display');
//Configure AuthComponent
$this->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
$this->Auth->logoutRedirect = array('controller' => 'users', 'action' => 'login');
$this->Auth->loginRedirect = array('controller' => 'users', 'action' => 'welcome');
$this->Auth->userScope = array('User.active' => 1);
}
我错过了什么?