CakePHP:设置ACL允许/拒绝不工作(表没有更新)?

时间:2012-01-09 18:50:53

标签: mysql cakephp acl cakephp-1.2

我正在尝试使用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');
    }

所以我跟着localhost/users/install,在回显函数中的一些数字之后,我意识到它已经运行了。但是,Cake给了我以下错误:

Error: The requested address '/users/install' was not found on this server.

我真的不知道问题是什么,但是我的acos / aros / aros_acos表在此之后都没有被触及。以下是来自以下查询的数据:

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)

编辑: 我将调试设置为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]

我还重新创建了我的DbAcl,它填充了acos表,但没有填充arosaros_acos表。上面的警告是我试图再次运行install操作。

2 个答案:

答案 0 :(得分:1)

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

app/config/core.php中将调试级别设置为2,以获得更好的错误消息。 “生产”设置使Cake为每个错误提供相同的消息。

答案 1 :(得分:0)

您是否尝试过此命令:

../ 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