laravel-acl
laravel-acl copied to clipboard
HasPermission middleware
Can you help me? I'm debugging around 2 hour your middleware, don't understanding why you provide an opportunity to override in config
'crud' => [
'restful' => [
//methods
],
'resource' => [
//methods
],
],
but don't provide to override
'crud' => [
'resources' => [
// controller actions
],
],
I have a situation, when sending ajax request and the package don't permits me do this, Says "You are not authorized to access this resource.". I'm trying to add to route group 'protect_methods' => ['view' => ['index', 'show', 'filter']] , where filter is method that I need, but the result still the same. Maybe I'm don't understanding can you help me ? I tried to override this middleware.
// my HasPermission middleware
protected function crudConfigOverride()
{
// Override crud restful from config.
if (($restful = config('acl.crud.restful')) != null) {
$this->crud['restful'] = $restful;
}
// Override crud resource from config.
if (($resource = config('acl.crud.resource')) != null) {
$this->crud['resource'] = $resource;
}
if (($resources = config('acl.crud.resources')) != null) {
$this->crud['resources'] = $resources;
}
}
// in config
'crud' => [
'resource' => [
'create' => ['create', 'store'],
'store' => ['create', 'store'],
'read' => ['index', 'show'],
'view' => ['index', 'show', 'filter'],
'edit' => ['edit', 'update'],
'update' => ['edit', 'update'],
'delete' => ['destroy'],
],
'resources' => [
'index',
'create',
'store',
'show',
'edit',
'update',
'destroy',
'filter',
],
],
All works right now. Maybe there any another solution ?
@IlyaSavich please refer to this wiki page
The main problem is that when the method that I defined was not found in crud => ['resources'] then HasPermission seeks through restful, but I don't need that. I tried all the options from the wiki, but the result remained the same
@kodeine, even using the protect_methods I still have 401. any updates?