Hi all,
I am using policy from Authorization\IdentityInterface to restrict access to my objects.
But for checking the access I need to fetch more information from database like
$workerstable = $this->fetchTable(‘workers’);
$worker = $workerstable->find()->where([‘user_id’ => $user->id])->first();
But when I run application, I get an error
Call to undefined method App\Policy\TicketPolicy::fetchTable()
My question is now, how do I get the fetchTable method in my Policy?
do I have to use Cake\ORM\Table?
use Cake\ORM\Locator\LocatorAwareTrait;
class TicketPolicy {
use LocatorAwareTrait;
public function canX($user, $resource, $action)
{
$workerstable = $this->fetchTable(‘workers’);
$worker = $workerstable->find()->where([‘user_id’ => $user->id])->first();
}
}
yes thanks a lot. I was reading documentation and found a way the restrict the access on functions in an object.
Even if you use the tables policy, you are able to handle the SQL statements too.
Thanks a lot for your support