Ok, I no longer get errors but the Owner() rule is not working.
In the bootstrap file I only load the cakedc/users plugin
Plugin::load('CakeDC/Users', ['bootstrap' => true, 'routes' => true]);
In the AppController
public function initialize()
{
parent::initialize();
$this->loadComponent('RequestHandler');
$this->loadComponent('Flash');
$this->loadComponent('CakeDC/Users.UsersAuth');
parent::initialize();
}
And permissions file:
return [
‘Users.SimpleRbac.permissions’ => [
//admin role allowed to all the things
[
‘role’ => ‘admin’,
‘prefix’ => ‘’,
‘extension’ => '’,
‘plugin’ => ‘’,
‘controller’ => '’,
‘action’ => ‘’,
],
//specific actions allowed for the all roles in Users plugin
[
‘role’ => '’,
‘plugin’ => ‘CakeDC/Users’,
‘controller’ => ‘Users’,
‘action’ => [‘profile’, ‘logout’, ‘linkSocial’, ‘callbackLinkSocial’],
],
[
‘role’ => ‘*’,
‘plugin’ => ‘CakeDC/Users’,
‘controller’ => ‘Users’,
‘action’ => ‘resetGoogleAuthenticator’,
‘allowed’ => function (array $user, $role, \Cake\Http\ServerRequest $request) {
$userId = \Cake\Utility\Hash::get($request->getAttribute(‘params’), ‘pass.0’);
if (!empty($userId) && !empty($user)) {
return $userId === $user[‘id’];
}
return false;
}
],
//all roles allowed to Pages/display
[
'role' => '*',
//'plugin' => null,
'controller' => 'Pages',
'action' => 'display',
],
[
'role' => 'user',
'controller' => 'Articles',
'action' => ['index','view'],
],
[
'role' => 'user',
'controller' => 'Users',
'action' => ['index','view'],
],
[
'role' => '*',
'controller' => 'Articles',
'action' => ['edit', 'delete'],
'allowed' => new \CakeDC\Auth\Rbac\Rules\Owner() //will pick by default the post id from the first pass param
],
]
];
Is there something I still do wrong?