Closed leandroruel closed 4 years ago
Did you inserted the records directly on database? The packages uses cache. Try clearing it first?
php artisan cache:clear
yes, cleaned all, just one question, can i use this package to block a route in a api? i'm trying pass the middleware at kernell file. in the api array. is it possible with this package?
the permission can "sync" with my api endpoint?
also, i'm using laravel 5.4, and using your trait hasRole, just returns this:
Call to undefined method Illuminate\Database\Query\Builder::canAtLeast()
I think YES, as long as the api routes are using the same User
instance that implements the HasRole
trait.
Are you using passport or just the standard api route? Will double check when I got the chance.
i'm using passport with api routes, but the method auth()->user()->hasRole()
give that error i show above. keep me updated if you figure out something wrong, or release a fix.
Your package has the best docs, would be great some example test files to make it more complete too and to study more the package.
And if it help you, i'm checking the roles and permissions in a custom middleware using your package, then i'm passing it to the api array.
Kernel.php
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
// \Illuminate\Session\Middleware\AuthenticateSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
\Laravel\Passport\Http\Middleware\CreateFreshApiToken::class,
],
'api' => [
'throttle:60,1',
'bindings',
'cors',
'checkRole',
],
];
Please open a new ticket if needed. Thanks!
i think i'm doing something wrong, not sure, i searched at stackoverflow but i not find anything related to this package, so i followed the installation tutorial at documentation, and inserted a admin permission to test a user, but even after that he keep returning "You are not authorized to access this resource."
i'm using a api route resource, like this:
this is my table: permissions this is my tabke: permissions_role