0
votes

I want to implement a group-only acl with CakeDc Users plugin. I followed cake's "Simple Acl controller Application guide". I have the following on User model:

public $belongsTo = array(
    'Role' => array(
        'className' => 'Role',
        'foreignKey' => 'role_id',
        'conditions' => '',
        'fields' => '',
        'order' => ''
    )
);

 public $actsAs = array('Acl' => array('type' => 'requester', 'enabled' => false));

 public function parentNode() {
    if (!$this->id && empty($this->data)) {
        return null;
    }
    if (isset($this->data['User']['role_id'])) {
        $roleId = $this->data['User']['role_id'];
    } else {
        $roleId = $this->field('role_id');
    }
    if (!$roleId) {
        return null;
    } else {
        return array('Role' => array('id' => $roleId));
    }
}

public function bindNode($user) {
    return array('model' => 'Model.Role', 'foreign_key' => $user['User']['role_id']);
}

And I have this on the Role model:

public $actsAs = array('Acl' => array('type' => 'requester'));

public function parentNode() {
    return null;
}
    public $hasMany = array(
    'User' => array(
        'className' => 'User',
        'foreignKey' => 'role_id',
        'dependent' => false,
        'conditions' => '',
        'fields' => '',
        'order' => '',
        'limit' => '',
        'offset' => '',
        'exclusive' => '',
        'finderQuery' => '',
        'counterQuery' => ''
    )
);

I doesn't seem to be working, it still asks me the aro.

AclNode::node() - Couldn't find Aro node identified by "Array ( [Aro0.model] => User [Aro0.foreign_key] => 51 ) "

What should I to correct thir error? Thanks in advance.

2

2 Answers

0
votes

In User.php try :

public function bindNode($user) {
    return array('model' => 'Role', 'foreign_key' => $user['User']['role_id']);
}

instead of

public function bindNode($user) {
    return array('model' => 'Model.Role', 'foreign_key' => $user['User']['role_id']);
}
-1
votes

Set the userModel for the AuthComponent's authorization methods. Its name is not-standard (User), as you are extending Users component's User model. Yet, Auth and Acl have to know.