Task policy:
class TaskPolicy
{
use HandlesAuthorization;
public function canSeeTeam()
{
return true;
}
}
AuthServiceProvider:
class AuthServiceProvider extends ServiceProvider
{
protected $policies = [
'AppModelsTask' => 'AppPoliciesTaskPolicy',
];
Task controller:
public function update(Request $request, Task $task)
{
$this->authorize('canSeeTeam');
dd('Authorized!');
}
Instead of getting Authorized!
I get:
"message": "This action is unauthorized.",
"exception": "SymfonyComponentHttpKernelExceptionAccessDeniedHttpException",
I’m logged in, and have access to the team, not it matters because canSeeTeam
always true
.
2
Answers
Please send me error message or replace this:
You also have to pass the task object to the authorize method: