Skip to content

Commit

Permalink
Merge pull request #1048 from arawa/fix/return-jsonresponse-middlewar…
Browse files Browse the repository at this point in the history
…e/stable3.2

fix(middleware): Return a JSONResponse
  • Loading branch information
zak39 authored Aug 22, 2024
2 parents 52bbf4d + 1de07db commit 68f042f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/Middleware/IsGeneralManagerMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,14 @@ public function beforeController($controller, $methodName): void {
return;
}

public function afterException($controller, $methodName, Exception $exception): void {
public function afterException($controller, $methodName, Exception $exception): JSONResponse {
if ($exception instanceof AccessDeniedException) {
return new JSONResponse([
'status' => 'forbidden',
'msg' => 'You are not allowed to perform this action'
], Http::STATUS_FORBIDDEN);
}

return new JSONResponse([]);
}
}

0 comments on commit 68f042f

Please sign in to comment.