Cakephp preventing ARO to check for user permissions

In cakephp most of us use ACL with Auth component to manage logins and access to various pages. When we need to implement this feature based on User Roles only. Sometimes the ARO checking gives error – that the User not exist for the foreign key. This is because if the role does not have required permission then the ACL tries to find the permission for logged user.

To prevent ARO from checking for user permissions when only role based access is needed, we need to add following lines in the User model. Please replace “Group” and “group_id” with your Model name used to manage the Role and foreign key name in User table for that respectively.

public function bindNode()  {
$data = AuthComponent::user();
return array('model' => 'Group', 'foreign_key' => $data['User']['group_id']);
}

This worked for me. It took me many hours to find this somewhere in Google. I am posting here so, you do not have to waste hours for this.

Scroll to top