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

@ -7,6 +7,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
### Fixed ### Fixed
* Fixes an exception when no token is entered on the 2-Factor enable/disable page and the form is submitted. * Fixes an exception when no token is entered on the 2-Factor enable/disable page and the form is submitted.
* Fixes an exception when trying to perform actions aganist a User model due to a validator that could not be cast to a string correctly. * Fixes an exception when trying to perform actions aganist a User model due to a validator that could not be cast to a string correctly.
* Allow FQDNs in database host creation UI correctly.
## v0.7.0 (Derelict Dermodactylus) ## v0.7.0 (Derelict Dermodactylus)
### Fixed ### Fixed

View File

@ -1,11 +1,4 @@
<?php <?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; namespace Pterodactyl\Http\Requests\Admin;
@ -18,14 +11,28 @@ class DatabaseHostFormRequest extends AdminFormRequest
*/ */
public function rules() public function rules()
{ {
if (! $this->filled('node_id')) {
$this->merge(['node_id' => null]);
}
if ($this->method() !== 'POST') { if ($this->method() !== 'POST') {
return DatabaseHost::getUpdateRulesForId($this->route()->parameter('host')); return DatabaseHost::getUpdateRulesForId($this->route()->parameter('host'));
} }
return DatabaseHost::getCreateRules(); 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();
}
} }