From 967153c70a785421aed42b209037c6f8c1a1c533 Mon Sep 17 00:00:00 2001 From: Deon George Date: Tue, 22 Oct 2024 19:33:24 +1100 Subject: [PATCH] Only admins can change the heartbeat below 12 --- app/Http/Requests/SystemRegisterRequest.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/Http/Requests/SystemRegisterRequest.php b/app/Http/Requests/SystemRegisterRequest.php index 50081e8..0bf2b12 100644 --- a/app/Http/Requests/SystemRegisterRequest.php +++ b/app/Http/Requests/SystemRegisterRequest.php @@ -34,6 +34,7 @@ class SystemRegisterRequest extends FormRequest public function messages(): array { return [ + 'heartbeat' => 'Sorry, only an admin can set this below 12', 'hold' => 'Must be Yes or No', 'pollmode' => 'Must be Hold, Normal or Crash', 'pkt_msgs' => 'Sorry, only an admin can increase this above 100', @@ -75,14 +76,23 @@ class SystemRegisterRequest extends FormRequest 'active' => 'required|boolean', 'hold' => 'sometimes|boolean', 'pollmode' => 'required|integer|min:0|max:2', - 'heartbeat' => 'nullable|integer|min:0|max:48', + 'heartbeat' => [ + 'nullable', + 'integer', + function ($attribute,$value,$fail) { + if (($value < 12) && (! Gate::allows('admin'))) + $fail(true); + }, + 'min:0', + 'max:48' + ], 'pkt_msgs' => [ 'nullable', + 'integer', function ($attribute,$value,$fail) { if (($value > 100) && (! Gate::allows('admin'))) $fail(true); }, - 'integer', 'min:5', 'max:65535', ],