質問

I'm using acl (followed cake's tutorial) in cake 2.4 and the FullCalendar plugin.

As for the FullCalendar plugin permisions are not working. I'm currently using the console to create aros, acos and granting permissions.

users table:

id | username | role_id
-----------------------
12 | company  | 2       
13 | regular  | 3      
14 | admin    | 1      

roles table:

id | role          
--------------------
12 | Administrador 
13 | Company       
14 | Regular       

aro table:

+----+-----------+-------+-------------+-------+------+------+
| id | parent_id | model | foreign_key | alias | lft  | rght |
+----+-----------+-------+-------------+-------+------+------+
|  1 |      NULL | Role  |           1 | NULL  |    1 |    4 |
|  2 |      NULL | Role  |           2 | NULL  |    5 |    8 |
|  3 |      NULL | Role  |           3 | NULL  |    9 |   12 |
|  4 |         1 | User  |          14 | NULL  |    2 |    3 |
|  5 |         2 | User  |          12 | NULL  |    6 |    7 |
|  6 |         3 | User  |          13 | NULL  |   10 |   11 |
+----+-----------+-------+-------------+-------+------+------+

The plugin is in this path: cake/app/Plugin/FullCalendar

-Controller
    -FullCalendarAppController
    -EventsController
    -FullCalendarController
    -EventTypesController
-Model
    -Event
    -EventType
    -FullCalendar
    -FullCalendarAppModel
-View
    -Events: add, edit, feed, index, view
    -EventTypes: add, edit, index, view
    -FullCalendar: index
    -Layouts 
-webroot

I've created this acos:

cake acl create aco controllers FullCalendar
cake acl create aco controllers/FullCalendar index
cake acl create aco controllers Events
cake acl create aco controllers/Events index
cake acl create aco controllers/Events view
cake acl create aco controllers/Events add

I want these permission:

Administrador: all

Company: index, view of the event list

/cake/full_calendar/events
/cake/full_calendar/events/view/1

Regular: index of the event list

/cake/full_calendar/events

and well, I used these to assing permissions:

cake acl grant Role.1 contollers/Fullcalendar all
cake acl grant Role.2 contollers/Fullcalendar/index all
cake acl grant Role.2 contollers/Fullcalendar/view all
cake acl grant Role.3 contollers/Fullcalendar/index all

This is the error I get:

Warning (512): DbAcl::check() - Failed ACO node lookup in permissions check. Node references:
Aro: Array
(
    [User] => Array
        (
            [id] => 14
            [username] => admin
            [role] => admin //this atribute was for testing, but i'm not using it anymore so I guess it doesn't really matters.
            [role_id] => 1
            [Role] => Array
            (
                [id] => 1
                [role] => Administrador
                [alias] => 
            )

    )

)

Aco: controllers/FullCalendar/Events/view [CORE\Cake\Model\Permission.php, line 103]

Also, would you mind telling what does the aros_acos' table "_create, _read, _update, _delete" mean?

Thanks in advance.

役に立ちましたか?

解決

You need to add the Plugin Name in the ACO path to resolve the ACO correctly.

Your current incorrect path:

controllers/Events/view

What it should be:

controllers/FullCalendar/Events/view

So to create the acos, first create a node for the Plugin:

cake acl create aco controllers FullCalendar

Then carry on like you would as below:

cake acl create aco controllers/FullCalendar FullCalendar
cake acl create aco controllers/FullCalendar/FullCalendar index
cake acl create aco controllers/FullCalendar Events
cake acl create aco controllers/FullCalendar/Events index
cake acl create aco controllers/FullCalendar/Events view
cake acl create aco controllers/FullCalendar/Events add

Additional debugging tip: Pay attention to that famous error that you are getting; you will get it quite a few times when implementing ACL. It will tell you what it is expecting and cannot find. E.g. in your case, Warning (512): DbAcl::check() - Failed **ACO** node lookup in permissions check. Hence check the ACO Node reference it wants:

Aco: controllers/FullCalendar/Events/view

This tells you that it is looking for the above node and cannot find it.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top