我的 Cake 网站上有一个简单的身份验证系统,只允许用户访问我的 posts_controller 的索引和 View ,但他们无法添加或编辑它们。我使用以下代码执行此操作:
function beforeFilter()
{
parent::beforeFilter();
$this->Auth->allow(array('index','view'));
}
现在这工作正常,因为他们只是重定向到登录页面,他们可以在其中登录以访问该页面,但没有获得访问权限,而是出现以下错误:
Warning (512): Could not find AclComponent. Please include Acl in Controller::$components. [CORE/cake/libs/controller/components/auth.php, line 421]
Notice (8): Undefined property: AuthComponent::$Acl [CORE/cake/libs/controller/components/auth.php, line 527]
Fatal error: Call to a member function check() on a non-object in /Users/cameron/Sites/cake-1.3.8/cake/libs/controller/components/auth.php on line 527
我不确定为什么会收到有关 ACL 的错误,因为我没有在应用程序中的任何位置使用 ACL,我所做的只是说明用户必须登录才能访问这些其他操作。
知道问题是什么以及如何解决它吗?
最佳答案
当您落在 AuthComponent 的第 527 行时,这是否意味着您在某个地方使用如下内容配置了 AuthComponent:
$this->Auth->authorize = 'actions';
如果是这种情况,则可以使 AuthComponent 使用 AclComponent 来检查是否允许用户执行操作。
参见http://book.cakephp.org/view/1250/Authentication#!/view/1275/authorize
关于php - CakePHP Acl问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5952661/