Reputation: 148
I'm trying to implement PDF functionality to my application. So, I added some new actions in controllers (like 'viewpdf'). After this, I rebuild the ACL tree with the build_acl action (from Mark Story Tutorial Automated tool for creating ACOS ). So, I can see with MySQL that a new node is created. Until this, everything is fine. But now I try to test the viewpdf button, and I get a 'You are not authorized to access that location.' error (even being admin). I check the error.log file and I see a warning:
> Aco: controllers/Specializations/viewpdf in [/usr/share/php/cake/libs/controller/components/acl.php, line 273]
2011-02-24 11:40:34 Warning: Warning (512): DbAcl::check() - Failed ARO/ACO node lookup in permissions check. Node references:
Aro: Array
(
[User] => Array
(
[id] => 1
[email] => [email protected]
[group_id] => 1
)
)
Aco: controllers/Specializations/viewpdf in [/usr/share/php/cake/libs/controller/components/acl.php, line 273]
Then I check the aros_acos table in the database and I see that there's no 'viewpdf' ACO related to any node, so there's an ARO, an ACO, but not an ARO_ACO, so I suppose that this is the reason why I'm getting this error.
¿Are my suppositions right? If they are, how could I create this aro_aco? I'm afraid that I could break anything if I do it manually...
Thanks in advance,
Alf.
Upvotes: 1
Views: 2158
Reputation: 2185
alfizqu,
if you have an ARO and an ACO but no connection between these by means of entries in the ACO_ARO table, this means you have not set up the permissions your AROs have on the ACOs.
Proceed like this:
/*
* Copied from the tutorial, and modified, this function initializes the per-
* missions for accessing controller actions.
*/
function initDB() {
$group =& $this->User->Group;
// A D M I N S
$group->id = 3;
$this->Acl->allow($group, 'controllers');
// M A N A G E R S
$group->id = 2;
$this->Acl->deny($group, 'controllers');
$this->Acl->allow($group, 'controllers/Items','*'); ... ...
Once you have set up such an initDB function, you have to run it once by calling it from your browser. If this does not suffice to help you back on the track, just go over the basic AUTH/ACL tutorial again. Yours, Benjamin.
Edit 1:
One of the crucial points is to call the parent::beforeFilter()
in the beforeFilter()
methods of self-defined controllers and properly setting up the app_controller
.
If these tips do not help, the most time-efficient way is to go over the ACL/AUTH tutorial very carefully, starting from a fresh cake environment. Once you can get it up and running there, you are confident to do it in your app.
Edit 2: And don't be afraid to throw out everything ACL/AUTH related of your app. It just sounds daunting, but it can safe a lot of debugging headaches/time.
P.S.: Btw there should be some moderately usable ACL/AUTH plugins at the bakery and one at sourceforge.
Upvotes: 1
Reputation: 17516
Try to create an sample action in users controller like this
function install(){
$aco = new Aco();
$aco->create();
$aco->save(array(
'parent_id' => <Id of the Specializations in acos table>,
'alias' => 'viewpdf',
));
$this->Acl->allow('admin','controllers/Specializations/viewpdf','*');
}
If u run the action the a new Aco node will be created in acos table. and for the admin user u can give the whole permission.you can use any valid user (username should be in Aros table) instead admin.
hope it helps.
Upvotes: 0