Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ACL in Cakephp 2.xx using custom tables

Tags:

cakephp

acl

I set up a custom Authentication system for my CakePHP application. Now we need to include some ACL to it. I followed the instructions here. Now for some reason I need to use the tables admin_users and admin_user_roles instead of the usual group and users. I can login fine but the ARO search fails. and it gives me the following error.

Warning (512): AclNode::node() - Couldn't find Aro node identified by "Array
(
    [Aro0.model] => User
    [Aro0.foreign_key] => 4
)
" [CORE/Cake/Model/AclNode.php, line 176]
Warning (512): DbAcl::check() - Failed ARO/ACO node lookup in permissions check.  Node          references:
    Aro: Array
    (
        [User] => Array
        (
            [id] => 4
            [admin_user_role_id] => 1
            [email] => [email protected]
            [username] => mio
            [created] => 2012-09-28 08:03:25
            [modified] => 2012-10-01 02:09:42
         )

)

Aco: controllers/Dashboard/index [CORE/Cake/Controller/Component/AclComponent.php, line 303]

It seems to still be looking for it in the User Model. Is there any way to change it so it looks for it in the AdminUsers table?

Looked in the DB and the Model field all point to AdminUser.

like image 922
miog Avatar asked Mar 07 '26 09:03

miog


1 Answers

Solved.

Added to Appcontroller this line

'authorize' => array(
'Actions' => array('userModel' => 'AdminUser','actionPath' => 'controllers')

Here AdminUser is the name of my model.

like image 185
miog Avatar answered Mar 10 '26 10:03

miog



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!