CakePHP:设置ACL允许/拒绝不工作(表不更新)? [英] CakePHP: Setting up ACL allow/deny not working (tables not being updated)?

查看:696
本文介绍了CakePHP:设置ACL允许/拒绝不工作(表不更新)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的UsersController中设置我的ACL与以下操作:

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');
    }

所以我按照 localhost / users / install ,并且在回调函数中的一些数字后,我意识到它运行。但是,Cake给我以下错误:

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.

我真的不知道是什么问题,但我的acos / aros / aros_acos表都是此后不变。以下是他们来自以下查询的数据:

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)

编辑:
我将debug设置为0,切换到2我收到以下警告:

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]



<表,但不是 aros aros_acos 表。上面的警告是我正在尝试再次运行安装操作。

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.

推荐答案

我认为您必须先创建控制器/消息等的ACOs,然后才能分配权限。

I think you have to create the ACOs for controllers/Messages etc before you you can assign permissions.

在<$ c $中设置调试级别为2 c> app / config / core.php 以获取更好的错误消息。 生产设置使蛋糕给每个错误相同的消息。

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.

这篇关于CakePHP:设置ACL允许/拒绝不工作(表不更新)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆