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.

1 Comment

  1. Gurunatha DogiApril 18, 2014

    Nice post…I have just started by coding on CakePHP for my company previously i was working on drupal and joomla…I just want to understand what is CakePHP? is it only used because of inbuilt classes and oops concept. I know that using CakePHP we can build websites rapidly but still want to know more on CakePHP. Please help me.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to top