Properly validate schedule names; closes #2405

This commit is contained in:
Dane Everitt 2020-09-24 19:25:34 -07:00
parent 48a104667f
commit 6a4914df3b
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
2 changed files with 10 additions and 7 deletions

View file

@ -2,6 +2,7 @@
namespace Pterodactyl\Http\Requests\Api\Client\Servers\Schedules;
use Pterodactyl\Models\Schedule;
use Pterodactyl\Models\Permission;
class StoreScheduleRequest extends ViewScheduleRequest
@ -19,13 +20,15 @@ class StoreScheduleRequest extends ViewScheduleRequest
*/
public function rules(): array
{
$rules = Schedule::getRules();
return [
'name' => 'required|string|min:1',
'is_active' => 'filled|boolean',
'minute' => 'required|string',
'hour' => 'required|string',
'day_of_month' => 'required|string',
'day_of_week' => 'required|string',
'name' => $rules['name'],
'is_active' => array_merge(['filled'], $rules['is_active']),
'minute' => $rules['cron_minute'],
'hour' => $rules['cron_hour'],
'day_of_month' => $rules['cron_day_of_month'],
'day_of_week' => $rules['cron_day_of_week'],
];
}
}

View file

@ -103,7 +103,7 @@ class Schedule extends Model
*/
public static $validationRules = [
'server_id' => 'required|exists:servers,id',
'name' => 'nullable|string|max:255',
'name' => 'required|string|max:255',
'cron_day_of_week' => 'required|string',
'cron_day_of_month' => 'required|string',
'cron_hour' => 'required|string',