问题
I am trying to set up my ACL with the following action in my UsersController:
class UsersController extends AppController {
var $name = 'Users';
var $helpers = array('Html', 'Form');
function beforeFilter() {
parent::beforeFilter();
$this->Auth->allow('*');
}
function install() {
$group =& $this->User->Group;
//Allow admins to everything
$group->id = 1;
$this->Acl->allow($group, 'controllers');
//allow users
$group->id = 2;
$this->Acl->deny($group, 'controllers');
$this->Acl->allow($group, 'controllers/Messages');
$this->Acl->allow($group, 'controllers/MessageLists');
$this->Acl->allow($group, 'controllers/Products');
$this->Acl->allow($group, 'controllers/Widgetviews');
}
So I follow localhost/users/install
, and after echoing some numbers in the function, I realized it ran. However, Cake gives me the following error:
Error: The requested address '/users/install' was not found on this server.
I don't really know what the problem is, but my acos/aros/aros_acos tables are all untouched after this. Here is their data from the following query:
mysql> select * from aros_acos a join acos c on a.aco_id=c.id join aros r on a.a
ro_id=r.id
-> ;
+----+--------+--------+---------+-------+---------+---------+----+-----------+-------+-------------+-------------+------+------+----+-----------+-------+-------------+-------+------+------+
| id | aro_id | aco_id | _create | _read | _update | _delete | id | parent_id | model | foreign_key | alias | lft | rght | id | parent_id | model | foreign_key | alias | lft | rght |
+----+--------+--------+---------+-------+---------+---------+----+-----------+-------+-------------+-------------+------+------+----+-----------+-------+-------------+-------+------+------+
| 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | NULL | NULL | NULL | controllers | 1 | 2 | 1 | NULL | Group | 1 | NULL | 1 | 4 |
| 2 | 2 | 1 | -1 | -1 | -1 | -1 | 1 | NULL | NULL | NULL | controllers | 1 | 2 | 2 | NULL | Group | 2 | NULL | 5 | 10 |
| 3 | 1 | 2 | 1 | 1 | 1 | 1 | 2 | NULL | NULL | NULL | controllers | 3 | 4 | 1 | NULL | Group | 1 | NULL | 1 | 4 |
| 4 | 2 | 2 | -1 | -1 | -1 | -1 | 2 | NULL | NULL | NULL | controllers | 3 | 4 | 2 | NULL | Group | 2 | NULL | 5 | 10 |
+----+--------+--------+---------+-------+---------+---------+----+-----------+-------+-------------+-------------+------+------+----+-----------+-------+-------------+-------+------+------+
4 rows in set (0.00 sec)
EDIT: I had debug set to 0, so after switching it to 2 I am getting the following warnings:
Warning (512): AclNode::node() - Couldn't find Aro node identified by "Array
(
[Aro0.model] => Group
[Aro0.foreign_key] => 1
)
" [CORE\cake\libs\model\db_acl.php, line 191]
Warning (512): DbAcl::allow() - Invalid node [CORE\cake\libs\controller\components\acl.php, line 324]
Warning (512): AclNode::node() - Couldn't find Aro node identified by "Array
(
[Aro0.model] => Group
[Aro0.foreign_key] => 2
)
" [CORE\cake\libs\model\db_acl.php, line 191]
I also re-created my DbAcl and it populated the acos
table but not the aros
or aros_acos
tables. The warning above is what I am getting trying to run the install
action again.
回答1:
I think you have to create the ACOs for controllers/Messages etc before you you can assign permissions.
Set your debug level to 2 in app/config/core.php
to get better error messages. The "production" setting makes Cake give the same message for every error.
回答2:
Did you try this command:
../cake/console/cake acl create aro root Groups
../cake/console/cake acl create aro root Group.1
../cake/console/cake acl create aro root Group.2
../cake/console/cake acl create aro root Group.3
来源:https://stackoverflow.com/questions/8793557/cakephp-setting-up-acl-allow-deny-not-working-tables-not-being-updated