CakeDC / users

Users Plugin for CakePHP
https://www.cakedc.com
Other
520 stars 296 forks source link

permissions #1001

Closed tgoeminne closed 2 weeks ago

tgoeminne commented 2 years ago

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

tgoeminne commented 2 years ago

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

ajibarra commented 1 month ago

@tgoeminne is there anything pending here?