From a4cf06ba77e84654c18da74057a6b1439fcf708f Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sun, 5 Nov 2017 12:58:25 -0600 Subject: [PATCH] Fix missing HASHIDS_SALT setting in app setup command, closes #724 --- CHANGELOG.md | 1 + app/Console/Commands/Environment/AppSettingsCommand.php | 4 ++++ app/Http/Requests/Server/ScheduleCreationFormRequest.php | 2 +- app/Providers/MacroServiceProvider.php | 2 +- app/helpers.php | 2 +- 5 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c8e8f8d3..598a258b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines. * `[beta.1]` — Fixes a CORS header issue due to a wrong API endpoint being provided in the administrative node listing. * `[beta.1]` — Fixes bug that would prevent root admins from accessing servers they were not set as the owner of. * `[beta.1]` — Fixes wrong URL redirect being provided when creating a subuser. +* `[beta.1]` — Fixes missing check in environment setup that would leave the Hashids salt empty. ## v0.7.0-beta.1 (Derelict Dermodactylus) ### Added diff --git a/app/Console/Commands/Environment/AppSettingsCommand.php b/app/Console/Commands/Environment/AppSettingsCommand.php index e197c9957..fbfa117f7 100644 --- a/app/Console/Commands/Environment/AppSettingsCommand.php +++ b/app/Console/Commands/Environment/AppSettingsCommand.php @@ -72,6 +72,10 @@ class AppSettingsCommand extends Command */ public function handle() { + if (empty($this->config->get('hashids.salt')) || $this->option('--new-salt')) { + $this->variables['HASHIDS_SALT'] = str_random(20); + } + $this->output->comment(trans('command/messages.environment.app.author_help')); $this->variables['APP_SERVICE_AUTHOR'] = $this->option('author') ?? $this->ask( trans('command/messages.environment.app.author'), $this->config->get('pterodactyl.service.author', 'unknown@unknown.com') diff --git a/app/Http/Requests/Server/ScheduleCreationFormRequest.php b/app/Http/Requests/Server/ScheduleCreationFormRequest.php index 2be18434f..b892605b7 100644 --- a/app/Http/Requests/Server/ScheduleCreationFormRequest.php +++ b/app/Http/Requests/Server/ScheduleCreationFormRequest.php @@ -69,7 +69,7 @@ class ScheduleCreationFormRequest extends ServerFormRequest { $restructured = []; foreach (array_get($this->all(), 'tasks', []) as $key => $values) { - for ($i = 0; $i < count($values); $i++) { + for ($i = 0; $i < count($values); ++$i) { $restructured[$i][$key] = $values[$i]; } } diff --git a/app/Providers/MacroServiceProvider.php b/app/Providers/MacroServiceProvider.php index 014e8f7af..ab6ab8926 100644 --- a/app/Providers/MacroServiceProvider.php +++ b/app/Providers/MacroServiceProvider.php @@ -31,7 +31,7 @@ class MacroServiceProvider extends ServiceProvider $i = 0; while (($size / 1024) > 0.9) { $size = $size / 1024; - $i++; + ++$i; } return round($size, ($i < 2) ? 0 : $precision) . ' ' . $units[$i]; diff --git a/app/helpers.php b/app/helpers.php index bfb12cc7a..0c9004695 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -20,7 +20,7 @@ if (! function_exists('human_readable')) { $i = 0; while (($path / 1024) > 0.9) { $path = $path / 1024; - $i++; + ++$i; } return round($path, $precision) . ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'][$i];