From 35b820cd7de904e50bd78cee197ebd379985ec58 Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Wed, 18 Sep 2019 14:09:30 +0200 Subject: Use 403 forbidden on shifts json, atom export and ical export --- includes/controller/shifts_controller.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'includes/controller') diff --git a/includes/controller/shifts_controller.php b/includes/controller/shifts_controller.php index caf124ba..726814cf 100644 --- a/includes/controller/shifts_controller.php +++ b/includes/controller/shifts_controller.php @@ -1,5 +1,6 @@ apiUser('key'); - if (!$request->has('key') || !preg_match('/^[\da-f]{32}$/', $request->input('key'))) { - engelsystem_error('Missing key.'); + if ( + !$request->has('key') + || !preg_match('/^[\da-f]{32}$/', $request->input('key')) + || !$user + ) { + throw new HttpForbidden('{"error":"Missing or invalid key"}', ['content-type' => 'application/json']); } - $user = auth()->apiUser('key'); - if (!$user) { - engelsystem_error('Key invalid.'); - } if (!auth()->can('shifts_json_export')) { - engelsystem_error('No privilege for shifts_json_export.'); + throw new HttpForbidden('{"error":"Not allowed"}', ['content-type' => 'application/json']); } $shifts = load_ical_shifts(); -- cgit v1.2.3-70-g09d2