CakePHP ACL gives error

2020-05-08 10:24发布

I've set this in my AppController.php

    $this->Auth->authorize = array(
    'Actions' => array(
        'actionPath' => 'controllers/'
    )
);

This is in my Aco table:

id  parent_id   model   foreign_key     alias   lft     rght
25  NULL             NULL   NULL    controllers     1   2

This is my Aro table:

id  parent_id   model   foreign_key     alias   lft     rght
1   1           Group   1               NULL      27    30
15  14          User    1               NULL      28    29

This is my Aco_Aro table:

id  aro_id  aco_id  _create     _read   _update     _delete
15    1       25      1             1     1            1

And i get this error:

    Warning (512): DbAcl::check() - Failed ARO/ACO node lookup in permissions check.  Node references:
Aro: Array
(
    [User] => Array
        (
            [id] => 1
            [username] => Test
            [group_id] => 1
            [created] => 2012-03-24 22:47:33
            [modified] => 2012-03-24 22:47:33
        )

)

Aco: controllers/Posts/index

标签: cakephp acl
1条回答
一夜七次
2楼-- · 2020-05-08 10:48

The user Test belongs the Aro 14 as seen in your Aro table. The parent_id field in the table Aro defines the tree.

// For eg. If i have two groups Administrator, User
Groups
id | name
11 | Administrator
22 | User

And Users // I have users table as

id | name | group_id
 7 |  KK  |    11
 9 |  SS  |    22

My Aro table would be

ARO
id | parent_id | alias | foreign_key  
 1 |   null    |  adm  |   11            // Group
 2 |   null    |  usr  |   22            // Group
 3 |    1      |  kk   |   7            // User
 4 |    2      |  SS   |   9            // User

From your Aro/Acl setup, cake's ACL component is not able to find 14. If you want to make your life easier you can try Acl Plugin. This really simplifies some obvious tasks.

查看更多
登录 后发表回答