Unable to Get CakePHP Cookbook Simple ACL Example Working

痴心易碎 提交于 2019-12-11 21:13:40

问题


I'm having problems getting ACL working with CakePHP. I've been working with the CakePHP Cookbook 2.0 example Simple Acl controlled Application, and have gone through the steps twice, but I've run into the same problem both times.

Everything appears to be setup correctly.

  • I'm able to create my groups, and users.
  • The aros table appears to have the same rows shown in the example on the web.
  • The acos and aros_acos tables appear to get populated with values that resemble the article.
  • And when I visit a page that's setup to be protected, I'm presented with the login page.

But when I login using the account I created, I see the following error:

Warning (512): DbAcl::check() - 
Failed ARO/ACO node lookup in permissions check.  Node     references:
Aro: Array
(
[User] => Array
    (
        [id] => 1
        [username] => dc
        [email] => myemail@somedomain.com
        [group_id] => 1
        [created] => 2011-10-27 14:58:59
        [modified] => 2011-10-27 14:58:59
    )
)  
Aco: /Posts/add [CORE/Cake/Controller/Component/AclComponent.php, line 303]

That account is setup as an administrator, and the administrator group has been granted access to everything ... so if it works, I shouldn't have a problem ... but it seems like there's a lower-level problem that's getting in my way. I can post my DB tables as well if that'd be helpful, but figured I'd start here. Thanks for any insight you can provide.


回答1:


The documentation was updated to address this issue. If you add this in the beforeFilter method in AppController it resolves the problem.

$this->Auth->authorize = array(
    AuthComponent::ALL => array('actionPath' => 'controllers'),
    'Actions',
);



回答2:


Add $this->Auth->allow('initDB'); in beforeFilter()



来源:https://stackoverflow.com/questions/7921664/unable-to-get-cakephp-cookbook-simple-acl-example-working

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!