cmd(setup): validate email input, closes #3175 (#3716)

This commit is contained in:
Alex 2021-12-04 20:52:09 +02:00 committed by GitHub
parent 0d5ff6afac
commit b8bf537737
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -12,6 +12,7 @@ namespace Pterodactyl\Console\Commands\Environment;
use DateTimeZone; use DateTimeZone;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Contracts\Console\Kernel; use Illuminate\Contracts\Console\Kernel;
use Illuminate\Validation\Factory as ValidatorFactory;
use Pterodactyl\Traits\Commands\EnvironmentWriterTrait; use Pterodactyl\Traits\Commands\EnvironmentWriterTrait;
use Illuminate\Contracts\Config\Repository as ConfigRepository; use Illuminate\Contracts\Config\Repository as ConfigRepository;
@ -78,12 +79,13 @@ class AppSettingsCommand extends Command
/** /**
* AppSettingsCommand constructor. * AppSettingsCommand constructor.
*/ */
public function __construct(ConfigRepository $config, Kernel $command) public function __construct(ConfigRepository $config, Kernel $command, ValidatorFactory $validator)
{ {
parent::__construct(); parent::__construct();
$this->command = $command;
$this->config = $config; $this->config = $config;
$this->command = $command;
$this->validator = $validator;
} }
/** /**
@ -103,6 +105,18 @@ class AppSettingsCommand extends Command
$this->config->get('pterodactyl.service.author', 'unknown@unknown.com') $this->config->get('pterodactyl.service.author', 'unknown@unknown.com')
); );
$validator = $this->validator->make(
['email' => $this->variables['APP_SERVICE_AUTHOR']],
['email' => 'email']
);
if ($validator->fails()) {
foreach ($validator->errors()->all() as $error) {
$this->output->error($error);
}
return 1;
}
$this->output->comment(trans('command/messages.environment.app.app_url_help')); $this->output->comment(trans('command/messages.environment.app.app_url_help'));
$this->variables['APP_URL'] = $this->option('url') ?? $this->ask( $this->variables['APP_URL'] = $this->option('url') ?? $this->ask(
trans('command/messages.environment.app.app_url'), trans('command/messages.environment.app.app_url'),