Closed zakariamehbi closed 3 years ago
I can't access this url : https://api.myapp.test/email-manager
My config
/** * Where should the admin route be? */ 'admin-route' => [ 'enabled' => true, // Should the admin routes be enabled? 'prefix' => 'email-manager', 'middleware' => [ 'web', 'can:see-sent-emails', ], ],
I did add the Gate
class AuthServiceProvider extends ServiceProvider { protected $policies = []; public function boot() { $this->registerPolicies(); Gate::define('see-sent-emails', function ($user) { return true; }); } }
I get this error :
{"message":"This action is unauthorized.","status_code":500,"debug":{"line":119,"file":"\/Users\/me\/Code\/myapp\/php-core\/app\/vendor\/laravel\/framework\/src\/Illuminate\/Auth\/Access\/Response.php","class":"Illuminate\\Auth\\Access\\AuthorizationException","trace":["#0 \/Users\/me\/Code\/myapp\/php-core\/app\/vendor\/laravel\/framework\/src\/Illuminate\/Auth\/Access\/Gate.php(322): Illuminate\\Auth\\Access\\Response->authorize()","#1 \/Users\/me\/Code\/myapp\/php-core\/app\/vendor\/laravel\/framework\/src\/Illuminate\/Auth\/Middleware\/Authorize.php(43): Illuminate\\Auth\\Access\\Gate->authorize('see-sent-emails', Array)","#2 \/Users\/me\/Code\/myapp\/php-core\/app\/vendor\/laravel\/framework\/src\/Illuminate\/Pipeline\/Pipeline.php(167): Illuminate\\Auth\\Middleware\\Authorize->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure), 'see-sent-emails')","#3 \/Users\/me\/Code\/myapp\/php-core\/app\/vendor\/laravel\/framework\/src\/Illuminate\/Routing\/Middleware\/SubstituteBindings.php(41): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))","#4 \/Users\/me\/Code\/myapp\/php-core\/app\/vendor\/laravel\/framework\/src\/Illuminate\/Pipeline\/Pipeline.php(167): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))","#5 \/Users\/me\/Code\/myapp\/php-core\/app\/vendor\/laravel\/framework\/src\/Illuminate\/Session\/Middleware\/AuthenticateSession.php(39): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))","#6 \/Users\/me\/Code\/myapp\/php-core\/app\/vendor\/laravel\/framework\/src\/Illuminate\/Pipeline\/Pipeline.php(167): Illuminate\\Session\\Middleware\\AuthenticateSession->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))","#7 \/Users\/me\/Code\/myapp\/php-core\/app\/vendor\/laravel\/framework\/src\/Illuminate\/View\/Middleware\/ShareErrorsFromSession.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))","#8 \/Users\/me\/Code\/myapp\/php-core\/app\/vendor\/laravel\/framework\/src\/Illuminate\/Pipeline\/Pipeline.php(167): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))","#9 \/Users\/me\/Code\/myapp\/php-core\/app\/vendor\/laravel\/framework\/src\/Illuminate\/Session\/Middleware\/StartSession.php(116): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))","#10 \/Users\/me\/Code\/myapp\/php-core\/app\/vendor\/laravel\/framework\/src\/Illuminate\/Session\/Middleware\/StartSession.php(62): Illuminate\\Session\\Middleware\\StartSession->handleStatefulRequest(Object(Dingo\\Api\\Http\\Request), Object(Illuminate\\Session\\Store), Object(Closure))","#11 \/Users\/me\/Code\/myapp\/php-core\/app\/vendor\/laravel\/framework\/src\/Illuminate\/Pipeline\/Pipeline.php(167): Illuminate\\Session\\Middleware\\StartSession->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))","#12 \/Users\/me\/Code\/myapp\/php-core\/app\/vendor\/laravel\/framework\/src\/Illuminate\/Cookie\/Middleware\/AddQueuedCookiesToResponse.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))","#13 \/Users\/me\/Code\/myapp\/php-core\/app\/vendor\/laravel\/framework\/src\/Illuminate\/Pipeline\/Pipeline.php(167): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))","#14 \/Users\/me\/Code\/myapp\/php-core\/app\/vendor\/laravel\/framework\/src\/Illuminate\/Cookie\/Middleware\/EncryptCookies.php(67): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))","#15 \/Users\/me\/Code\/myapp\/php-core\/app\/vendor\/laravel\/framework\/src\/Illuminate\/Pipeline\/Pipeline.php(167): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))","#16 \/Users\/me\/Code\/myapp\/php-core\/app\/vendor\/laravel\/framework\/src\/Illuminate\/Pipeline\/Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))","#17 \/Users\/me\/Code\/myapp\/php-core\/app\/vendor\/laravel\/framework\/src\/Illuminate\/Routing\/Router.php(687): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))","#18 \/Users\/me\/Code\/myapp\/php-core\/app\/vendor\/laravel\/framework\/src\/Illuminate\/Routing\/Router.php(662): Illuminate\\Routing\\Router->runRouteWithinStack(Object(Illuminate\\Routing\\Route), Object(Dingo\\Api\\Http\\Request))","#19 \/Users\/me\/Code\/myapp\/php-core\/app\/vendor\/laravel\/framework\/src\/Illuminate\/Routing\/Router.php(628): Illuminate\\Routing\\Router->runRoute(Object(Dingo\\Api\\Http\\Request), Object(Illuminate\\Routing\\Route))","#20 \/Users\/me\/Code\/myapp\/php-core\/app\/vendor\/laravel\/framework\/src\/Illuminate\/Routing\/Router.php(617): Illuminate\\Routing\\Router->dispatchToRoute(Object(Dingo\\Api\\Http\\Request))","#21 \/Users\/me\/Code\/myapp\/php-core\/app\/vendor\/dingo\/api\/src\/Routing\/Adapter\/Laravel.php(88): Illuminate\\Routing\\Router->dispatch(Object(Dingo\\Api\\Http\\Request))","#22 \/Users\/me\/Code\/myapp\/php-core\/app\/vendor\/dingo\/api\/src\/Routing\/Router.php(518): Dingo\\Api\\Routing\\Adapter\\Laravel->dispatch(Object(Dingo\\Api\\Http\\Request), 'v1')","#23 \/Users\/me\/Code\/myapp\/php-core\/app\/vendor\/dingo\/api\/src\/Http\/Middleware\/Request.php(126): Dingo\\Api\\Routing\\Router->dispatch(Object(Dingo\\Api\\Http\\Request))","#24 \/Users\/me\/Code\/myapp\/php-core\/app\/vendor\/laravel\/framework\/src\/Illuminate\/Pipeline\/Pipeline.php(128): Dingo\\Api\\Http\\Middleware\\Request->Dingo\\Api\\Http\\Middleware\\{closure}(Object(Dingo\\Api\\Http\\Request))","#25 \/Users\/me\/Code\/myapp\/php-core\/app\/vendor\/fruitcake\/laravel-cors\/src\/HandleCors.php(52): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))","#26 \/Users\/me\/Code\/myapp\/php-core\/app\/vendor\/laravel\/framework\/src\/Illuminate\/Pipeline\/Pipeline.php(167): Fruitcake\\Cors\\HandleCors->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))","#27 \/Users\/me\/Code\/myapp\/php-core\/app\/vendor\/fideloper\/proxy\/src\/TrustProxies.php(57): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))","#28 \/Users\/me\/Code\/myapp\/php-core\/app\/vendor\/laravel\/framework\/src\/Illuminate\/Pipeline\/Pipeline.php(167): Fideloper\\Proxy\\TrustProxies->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))","#29 \/Users\/me\/Code\/myapp\/php-core\/app\/vendor\/laravel\/framework\/src\/Illuminate\/Foundation\/Http\/Middleware\/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))","#30 \/Users\/me\/Code\/myapp\/php-core\/app\/vendor\/laravel\/framework\/src\/Illuminate\/Pipeline\/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))","#31 \/Users\/me\/Code\/myapp\/php-core\/app\/vendor\/laravel\/framework\/src\/Illuminate\/Foundation\/Http\/Middleware\/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))","#32 \/Users\/me\/Code\/myapp\/php-core\/app\/vendor\/laravel\/framework\/src\/Illuminate\/Pipeline\/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))","#33 \/Users\/me\/Code\/myapp\/php-core\/app\/vendor\/laravel\/framework\/src\/Illuminate\/Foundation\/Http\/Middleware\/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))","#34 \/Users\/me\/Code\/myapp\/php-core\/app\/vendor\/laravel\/framework\/src\/Illuminate\/Pipeline\/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))","#35 \/Users\/me\/Code\/myapp\/php-core\/app\/vendor\/laravel\/framework\/src\/Illuminate\/Foundation\/Http\/Middleware\/CheckForMaintenanceMode.php(63): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))","#36 \/Users\/me\/Code\/myapp\/php-core\/app\/vendor\/laravel\/framework\/src\/Illuminate\/Pipeline\/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))","#37 \/Users\/me\/Code\/myapp\/php-core\/app\/vendor\/laravel\/framework\/src\/Illuminate\/Pipeline\/Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))","#38 \/Users\/me\/Code\/myapp\/php-core\/app\/vendor\/dingo\/api\/src\/Http\/Middleware\/Request.php(127): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))","#39 \/Users\/me\/Code\/myapp\/php-core\/app\/vendor\/dingo\/api\/src\/Http\/Middleware\/Request.php(103): Dingo\\Api\\Http\\Middleware\\Request->sendRequestThroughRouter(Object(Dingo\\Api\\Http\\Request))","#40 \/Users\/me\/Code\/myapp\/php-core\/app\/vendor\/laravel\/framework\/src\/Illuminate\/Pipeline\/Pipeline.php(167): Dingo\\Api\\Http\\Middleware\\Request->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))","#41 \/Users\/me\/Code\/myapp\/php-core\/app\/vendor\/laravel\/framework\/src\/Illuminate\/Pipeline\/Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))","#42 \/Users\/me\/Code\/myapp\/php-core\/app\/vendor\/laravel\/framework\/src\/Illuminate\/Foundation\/Http\/Kernel.php(140): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))","#43 \/Users\/me\/Code\/myapp\/php-core\/app\/vendor\/laravel\/framework\/src\/Illuminate\/Foundation\/Http\/Kernel.php(109): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))","#44 \/Users\/me\/Code\/myapp\/php-core\/app\/public\/index.php(69): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))","#45 \/Users\/me\/.composer\/vendor\/laravel\/valet\/server.php(219): require('\/Users\/zakariam...')","#46 {main}"]}}
It looks right to me, are you sure you are logged in? I'm going to close this as this is more of a Laravel-level tech support question and not a bug in this package.
I can't access this url : https://api.myapp.test/email-manager
My config
I did add the Gate
I get this error :