mirror of
https://github.com/pterodactyl/panel.git
synced 2024-11-22 17:12:30 +01:00
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 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]` — Fixes a bug that would cause non-editable variables on the front-end to throw a validation error.
|
||||
|
||||
### Added
|
||||
* 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
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||
* @throws \Illuminate\Validation\ValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
|
@ -76,6 +76,12 @@ class VariableValidatorService
|
||||
|
||||
$data = $rules = $customAttributes = [];
|
||||
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);
|
||||
$rules['environment.' . $variable->env_variable] = $variable->rules;
|
||||
$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();
|
||||
|
||||
$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', [
|
||||
'attribute' => trans('validation.internal.variable_value', ['env' => $variables[$i]->name]),
|
||||
]), $messages[$i]);
|
||||
@ -148,8 +151,8 @@ class VariableValidatorServiceTest extends TestCase
|
||||
return collect(
|
||||
[
|
||||
factory(EggVariable::class)->states('editable', 'viewable')->make(),
|
||||
factory(EggVariable::class)->states('viewable')->make(),
|
||||
factory(EggVariable::class)->states('editable')->make(),
|
||||
factory(EggVariable::class)->states('viewable')->make(),
|
||||
factory(EggVariable::class)->make(),
|
||||
]
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user