Hey everyone,
I’m just trying to implement my authentication and it works well and i can only access the right houses.
I tried to break the authentication by changing the URL from this
http://localhost/hausundhof/houses/view/6
to this.
http://localhost/hausundhof/houses/view/7
Now i get the following error message.
Authorization check method must return
Authorization\Policy\ResultInterface
orbool
.
That seems like not the right Error.
# UserPolicy.php
<?php
declare(strict_types=1);
namespace App\Policy;
use App\Model\Entity\User;
use Authorization\IdentityInterface;
class UserPolicy
{
public function canView(IdentityInterface $user, User $resource)
{
return $user->getIdentifier() === $resource->id;
}
}
# UserController.php
public function view($id = null)
{
$user = $this->Users->get($id, contain: ['Roles', 'Houses', 'TicketSnaps', 'Tickets']);
$this->Authorization->authorize($user, 'view');
$this->set(compact('user'));
}
Mache ich da irgendetwas falsch??
Merci