我正在尝试在路由组上使用策略。我已经包含了绑定中间件,并试图在CAN中间件中列出ACTION和MODEL。
由于某种原因,它保留returning 403
。可能我不太了解这些政策的运作方式。
我正在尝试在策略中输入before方法,但是保留returning 403
。如果有人解释我应该如何在中间件中列出自定义方法,那也很可爱。
我也确实在AuthServiceProvider
protected $policies = [
Service::class => ServicePolicy::class,
];
public function before(CustomAuth0User $user, Service $service)
{
dd($service);
}
Route::group(['prefix' => 'services', 'namespace' => 'Services', 'middleware' => ['bindings', 'can:getCancel, service']], function () {
Route::get('/{service}/cancel', 'ServiceController@getCancel');
Route::post('/{service}/cancel', 'ServiceController@postCancel');
Route::get('/{id}/reassign', 'ServiceController@getReassign');
Route::post('/{id}/reassign', 'ServiceController@postReassign');
Route::get('/{id}/close', 'ServiceController@getClose');
Route::post('/{id}/close', 'ServiceController@postClose');
Route::get('/{id}/history', 'ServiceController@getHistory');
});
Controller
public function getCancel(Service $service)
{
dd($service);
}