From 3752fdec4c165239ecbacd86daf19a7fa905a586 Mon Sep 17 00:00:00 2001 From: Jeppe Bundgaard Date: Thu, 19 Mar 2026 14:39:23 +0100 Subject: [PATCH] Add support for "forbidden" response with missing permissions in Nginx response handler --- services/nginx/app/classes/response.php | 8 ++++++++ services/nginx/app/interfaces/response_i.php | 1 + 2 files changed, 9 insertions(+) diff --git a/services/nginx/app/classes/response.php b/services/nginx/app/classes/response.php index f6bb61db..e3703f38 100644 --- a/services/nginx/app/classes/response.php +++ b/services/nginx/app/classes/response.php @@ -101,6 +101,14 @@ class response implements response_i $this->error('Internal server error' . ($error ? ': ' . $error : ''), 500); } + #[NoReturn] public function forbidden(array $permissions): void + { + $this->error([ + 'message' => 'Missing permission(s)', + 'permissions' => $permissions + ], 403); + } + public function paginate(int $page, int $per_page, int $total, string $search = null, array $filters = null, array $order = null): void { // If the total is 0, return 1 page, 0 total diff --git a/services/nginx/app/interfaces/response_i.php b/services/nginx/app/interfaces/response_i.php index 9bda6a89..69e89c61 100644 --- a/services/nginx/app/interfaces/response_i.php +++ b/services/nginx/app/interfaces/response_i.php @@ -11,6 +11,7 @@ interface response_i public function matching_route_found(): void; public function method_not_allowed(): void; public function internal_server_error($error): void; + public function forbidden(array $permissions): void; public function add_data(string $key, mixed $value): void; public function add_debug(mixed $data): void; } \ No newline at end of file