I have trouble using ACL. In my CoreUsersController i make the following call:
if(!$this->Acl->check('User::'.$user['User']['id'], 'CoreUser', 'read')) {
die('PERM DENIED');
}
The ACL is included as component in my AppController. The Database-Tables looks like:
- table "acos"
- table "core_groups" (as aros)
- table "aros_acos" as connection between core_groups and acos.
Here is the Error Thrown: Error: Table aros for model Aro was not found in datasource default.
And my Code:
1. User-Model:
App::uses('AuthComponent', 'Controller/Component');
class CoreUser extends AppModel {
public $useDbConfig = 'default';
public $useTable = 'core_users';
public $hasAndBelongsToMany = array(
'MemberOf' => array(
'className' => 'CoreGroup',
'joinTable' => 'core_users_groups',
'foreignKey' => 'user_id',
'associationForeignKey' => 'group_id'
)
);
public $name = 'User';
public $actsAs = array('Acl' => array('type' => 'both'));
public function parentNode() {
// stuff in here should be correct
}
}
2. Group-Model:
App::uses('AppModel', 'Model');
App::uses('AuthComponent', 'Controller/Component');
class CoreGroup extends AppModel {
public $useDbConfig = 'default';
public $useTable = 'core_groups';
public $hasAndBelongsToMany = array(
'Member' => array(
'className' => 'CoreUser',
'joinTable' => 'core_users_groups',
'foreignKey' => 'group_id',
'associationForeignKey' => 'user_id'
)
);
public $name = 'Group';
public $actsAs = array('Acl' => array('type' => 'requester'));
public function parentNode() {
return null;
}
}
My Question: How to tell ACL to use "core_groups"-Table instead of "aros"-table? Note: I added "ActsAs" as suggested by the Cake-Book to both Models!