Fix FQDN failing validation in database host UI, ref #957

This commit is contained in:
Dane Everitt 2018-02-18 13:43:54 -06:00
parent c61c2bc5fd
commit 3fb02a4b3c
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
2 changed files with 19 additions and 11 deletions

View file

@ -1,11 +1,4 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Http\Requests\Admin;
@ -18,14 +11,28 @@ class DatabaseHostFormRequest extends AdminFormRequest
*/
public function rules()
{
if (! $this->filled('node_id')) {
$this->merge(['node_id' => null]);
}
if ($this->method() !== 'POST') {
return DatabaseHost::getUpdateRulesForId($this->route()->parameter('host'));
}
return DatabaseHost::getCreateRules();
}
/**
* Modify submitted data before it is passed off to the validator.
*
* @return \Illuminate\Contracts\Validation\Validator
*/
protected function getValidatorInstance()
{
if (! $this->filled('node_id')) {
$this->merge(['node_id' => null]);
}
$this->merge([
'host' => gethostbyname($this->input('host')),
]);
return parent::getValidatorInstance();
}
}