parent
6812234119
commit
fe7a7e5970
2 changed files with 29 additions and 7 deletions
@ -0,0 +1,18 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace App\Exceptions\Renderers; |
||||||
|
|
||||||
|
use Illuminate\Http\Request; |
||||||
|
use Spatie\Permission\Exceptions\UnauthorizedException; |
||||||
|
use Symfony\Component\HttpFoundation\Response; |
||||||
|
|
||||||
|
class PermissionExceptionRenderer |
||||||
|
{ |
||||||
|
public function __invoke(UnauthorizedException $e, Request $request): Response |
||||||
|
{ |
||||||
|
return response()->json([ |
||||||
|
'message' => 'Bạn không có quyền truy cập.', |
||||||
|
'required' => $e->getRequiredRoles() ?? $e->getRequiredPermissions(), |
||||||
|
], 403); |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue