diff --git a/app/Http/Requests/SystemRegisterRequest.php b/app/Http/Requests/SystemRegisterRequest.php index aa77743..50081e8 100644 --- a/app/Http/Requests/SystemRegisterRequest.php +++ b/app/Http/Requests/SystemRegisterRequest.php @@ -23,7 +23,12 @@ class SystemRegisterRequest extends FormRequest // @todo Also disallow claiming this hosts system - return Gate::allows($this->route('o')->users->count() ? 'update_nn' : 'register',$this->route('o')); + return Gate::allows( + $this->route('o')->users->count() + ? 'update_nn' + : 'register', + $this->route('o') + ); } public function messages(): array @@ -31,6 +36,7 @@ class SystemRegisterRequest extends FormRequest return [ 'hold' => 'Must be Yes or No', 'pollmode' => 'Must be Hold, Normal or Crash', + 'pkt_msgs' => 'Sorry, only an admin can increase this above 100', ]; } @@ -39,7 +45,7 @@ class SystemRegisterRequest extends FormRequest * * If the system exists (POST & action="register" & system_id=), then no validation required * If the system doesnt exist (POST & action="register" & system_id undefined) then we need just a name to start the process (action="create") - * Then, full validation + * Then, full validation * @return array */ public function rules(Request $request) @@ -70,7 +76,16 @@ class SystemRegisterRequest extends FormRequest 'hold' => 'sometimes|boolean', 'pollmode' => 'required|integer|min:0|max:2', 'heartbeat' => 'nullable|integer|min:0|max:48', - 'pkt_msgs' => 'nullable|integer|min:5', + 'pkt_msgs' => [ + 'nullable', + function ($attribute,$value,$fail) { + if (($value > 100) && (! Gate::allows('admin'))) + $fail(true); + }, + 'integer', + 'min:5', + 'max:65535', + ], ] : [])); } } \ No newline at end of file