Fixes a bug that would cause non-editable variables on the front-end to throw a validation error
This commit is contained in:
parent
e2cdb3b4b1
commit
8e1aa15dba
|
@ -11,6 +11,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
|
||||||
* `[rc.2]` — Fix data integrity exception occuring due to invalid data being passed to server creation service on the API.
|
* `[rc.2]` — Fix data integrity exception occuring due to invalid data being passed to server creation service on the API.
|
||||||
* `[rc.2]` — Fix data integrity exception that could occur when an email containing non-username characters was passed.
|
* `[rc.2]` — Fix data integrity exception that could occur when an email containing non-username characters was passed.
|
||||||
* `[rc.2]` — Fix data integrity exception occurring when no default value is provided for an egg variable.
|
* `[rc.2]` — Fix data integrity exception occurring when no default value is provided for an egg variable.
|
||||||
|
* `[rc.2]` — Fixes a bug that would cause non-editable variables on the front-end to throw a validation error.
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
* Added ability to search the following API endpoints: list users, list servers, and list locations.
|
* Added ability to search the following API endpoints: list users, list servers, and list locations.
|
||||||
|
|
|
@ -81,6 +81,7 @@ class StartupController extends Controller
|
||||||
* @return \Illuminate\Http\RedirectResponse
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
*
|
*
|
||||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||||
|
* @throws \Illuminate\Validation\ValidationException
|
||||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -76,6 +76,12 @@ class VariableValidatorService
|
||||||
|
|
||||||
$data = $rules = $customAttributes = [];
|
$data = $rules = $customAttributes = [];
|
||||||
foreach ($variables as $variable) {
|
foreach ($variables as $variable) {
|
||||||
|
// Don't attempt to validate variables if they aren't user editable
|
||||||
|
// and we're not running this at an admin level.
|
||||||
|
if (! $variable->user_editable && ! $this->isUserLevel(User::USER_LEVEL_ADMIN)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$data['environment'][$variable->env_variable] = array_get($fields, $variable->env_variable);
|
$data['environment'][$variable->env_variable] = array_get($fields, $variable->env_variable);
|
||||||
$rules['environment.' . $variable->env_variable] = $variable->rules;
|
$rules['environment.' . $variable->env_variable] = $variable->rules;
|
||||||
$customAttributes['environment.' . $variable->env_variable] = trans('validation.internal.variable_value', ['env' => $variable->name]);
|
$customAttributes['environment.' . $variable->env_variable] = trans('validation.internal.variable_value', ['env' => $variable->name]);
|
||||||
|
|
|
@ -128,9 +128,12 @@ class VariableValidatorServiceTest extends TestCase
|
||||||
$messages = $exception->validator->getMessageBag()->all();
|
$messages = $exception->validator->getMessageBag()->all();
|
||||||
|
|
||||||
$this->assertNotEmpty($messages);
|
$this->assertNotEmpty($messages);
|
||||||
$this->assertSame(4, count($messages));
|
$this->assertSame(2, count($messages));
|
||||||
|
|
||||||
for ($i = 0; $i < 4; $i++) {
|
// We only expect to get the first two variables form the getVariableCollection
|
||||||
|
// function here since those are the only two that are editable, and the others
|
||||||
|
// should be discarded and not validated.
|
||||||
|
for ($i = 0; $i < 2; $i++) {
|
||||||
$this->assertSame(trans('validation.required', [
|
$this->assertSame(trans('validation.required', [
|
||||||
'attribute' => trans('validation.internal.variable_value', ['env' => $variables[$i]->name]),
|
'attribute' => trans('validation.internal.variable_value', ['env' => $variables[$i]->name]),
|
||||||
]), $messages[$i]);
|
]), $messages[$i]);
|
||||||
|
@ -148,8 +151,8 @@ class VariableValidatorServiceTest extends TestCase
|
||||||
return collect(
|
return collect(
|
||||||
[
|
[
|
||||||
factory(EggVariable::class)->states('editable', 'viewable')->make(),
|
factory(EggVariable::class)->states('editable', 'viewable')->make(),
|
||||||
factory(EggVariable::class)->states('viewable')->make(),
|
|
||||||
factory(EggVariable::class)->states('editable')->make(),
|
factory(EggVariable::class)->states('editable')->make(),
|
||||||
|
factory(EggVariable::class)->states('viewable')->make(),
|
||||||
factory(EggVariable::class)->make(),
|
factory(EggVariable::class)->make(),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue