【发布时间】:2012-09-06 13:30:17
【问题描述】:
我找不到解决问题的方法。 我有一个使用 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);
}
我错过了什么?
【问题讨论】:
-
你使用的是 cakePHP 2.0 还是 1.3?
标签: php cakephp acl before-filter