简体   繁体   English

CakePHP:设置ACL允许/拒绝功能不起作用(表未更新)?

[英]CakePHP: Setting up ACL allow/deny not working (tables not being updated)?

I am trying to set up my ACL with the following action in my UsersController: 我试图在我的UsersController中通过以下操作设置我的ACL:

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. 所以我遵循localhost/users/install ,并且在函数中回显了一些数字之后,我意识到它已经运行了。 However, Cake gives me the following error: 但是,Cake给我以下错误:

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. 我真的不知道问题出在哪里,但是在此之后,我的acos / aros / aros_acos表都保持不变。 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: 编辑:我已将调试设置为0,所以将其切换为2后,我得到以下警告:

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. 我还重新创建了DbAcl,并填充了acos表,但没有填充arosaros_acos表。 The warning above is what I am getting trying to run the install action again. 上面的警告是我试图再次运行install操作的原因。

I think you have to create the ACOs for controllers/Messages etc before you you can assign permissions. 我认为您必须先为控制器/消息等创建ACO,然后才能分配权限。

Set your debug level to 2 in app/config/core.php to get better error messages. app/config/core.php中将调试级别设置为2,以获得更好的错误消息。 The "production" setting makes Cake give the same message for every error. “生产”设置使Cake对每个错误都给出相同的消息。

Did you try this command: 您是否尝试过以下命令:

../cake/console/cake acl create aro root Groups ../cake/console/cake acl创建ARO根组

../cake/console/cake acl create aro root Group.1 ../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.2

../cake/console/cake acl create aro root Group.3 ../cake/console/cake acl create aro root Group.3

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM