CakeDC/users

permissions

tgoeminne opened this issue · 2 comments

use example from documentation not working as expected
This shown in documentation throws errors
'allowed' => function (array $user, $role, \Cake\Http\ServerRequest $request) {
$postId = \Cake\Utility\Hash::get($request->params, 'pass.0');
$post = \Cake\ORM\TableRegistry::get('Posts')->get($postId);
$userId = $user['id'];
if (!empty($post->user_id) && !empty($userId)) {
return $post->user_id === $userId;
}
return false;
}

Cake\Core\Configure\Engine\PhpConfig::{closure}(): Argument #1 ($user) must be of type array, CakeDC\Users\Model\Entity\User given

Then change array $user to CakeDC\Users\Model\Entity\User $user

get error : Cannot access protected property Cake\Http\ServerRequest::$params

You need to use $request->getAttribute('params') like it was before