From e49ba657094fc009387b567fe5d8c8a97f4a40ee Mon Sep 17 00:00:00 2001 From: Lance Pioch Date: Sun, 23 Oct 2022 20:51:20 -0400 Subject: [PATCH] Fix config key names (#4464) --- .../Environment/EmailSettingsCommand.php | 8 +++--- app/Console/Commands/InfoCommand.php | 11 ++++---- .../Admin/Settings/MailController.php | 4 +-- app/Http/Controllers/Admin/UserController.php | 3 +- .../Requests/Admin/NewUserFormRequest.php | 28 +++++++++++++++++++ app/Providers/SettingsServiceProvider.php | 2 +- resources/views/admin/settings/mail.blade.php | 8 +++--- 7 files changed, 47 insertions(+), 17 deletions(-) create mode 100644 app/Http/Requests/Admin/NewUserFormRequest.php diff --git a/app/Console/Commands/Environment/EmailSettingsCommand.php b/app/Console/Commands/Environment/EmailSettingsCommand.php index cae0094c0..1fd9a2aee 100644 --- a/app/Console/Commands/Environment/EmailSettingsCommand.php +++ b/app/Console/Commands/Environment/EmailSettingsCommand.php @@ -49,7 +49,7 @@ class EmailSettingsCommand extends Command 'mandrill' => 'Mandrill Transactional Email', 'postmark' => 'Postmark Transactional Email', ], - $this->config->get('mail.driver', 'smtp') + $this->config->get('mail.default', 'smtp') ); $method = 'setup' . studly_case($this->variables['MAIL_DRIVER']) . 'DriverVariables'; @@ -86,17 +86,17 @@ class EmailSettingsCommand extends Command { $this->variables['MAIL_HOST'] = $this->option('host') ?? $this->ask( trans('command/messages.environment.mail.ask_smtp_host'), - $this->config->get('mail.host') + $this->config->get('mail.mailers.smtp.host') ); $this->variables['MAIL_PORT'] = $this->option('port') ?? $this->ask( trans('command/messages.environment.mail.ask_smtp_port'), - $this->config->get('mail.port') + $this->config->get('mail.mailers.smtp.port') ); $this->variables['MAIL_USERNAME'] = $this->option('username') ?? $this->ask( trans('command/messages.environment.mail.ask_smtp_username'), - $this->config->get('mail.username') + $this->config->get('mail.mailers.smtp.username') ); $this->variables['MAIL_PASSWORD'] = $this->option('password') ?? $this->secret( diff --git a/app/Console/Commands/InfoCommand.php b/app/Console/Commands/InfoCommand.php index bc1d11792..25c774405 100644 --- a/app/Console/Commands/InfoCommand.php +++ b/app/Console/Commands/InfoCommand.php @@ -58,15 +58,16 @@ class InfoCommand extends Command ['Username', $this->config->get("database.connections.$driver.username")], ], 'compact'); + // TODO: Update this to handle other mail drivers $this->output->title('Email Configuration'); $this->table([], [ - ['Driver', $this->config->get('mail.driver')], - ['Host', $this->config->get('mail.host')], - ['Port', $this->config->get('mail.port')], - ['Username', $this->config->get('mail.username')], + ['Driver', $this->config->get('mail.default')], + ['Host', $this->config->get('mail.mailers.smtp.host')], + ['Port', $this->config->get('mail.mailers.smtp.port')], + ['Username', $this->config->get('mail.mailers.smtp.username')], ['From Address', $this->config->get('mail.from.address')], ['From Name', $this->config->get('mail.from.name')], - ['Encryption', $this->config->get('mail.encryption')], + ['Encryption', $this->config->get('mail.mailers.smtp.encryption')], ], 'compact'); } diff --git a/app/Http/Controllers/Admin/Settings/MailController.php b/app/Http/Controllers/Admin/Settings/MailController.php index 058e3a90e..2db87fd58 100644 --- a/app/Http/Controllers/Admin/Settings/MailController.php +++ b/app/Http/Controllers/Admin/Settings/MailController.php @@ -39,7 +39,7 @@ class MailController extends Controller public function index(): View { return $this->view->make('admin.settings.mail', [ - 'disabled' => $this->config->get('mail.driver') !== 'smtp', + 'disabled' => $this->config->get('mail.default') !== 'smtp', ]); } @@ -52,7 +52,7 @@ class MailController extends Controller */ public function update(MailSettingsFormRequest $request): Response { - if ($this->config->get('mail.driver') !== 'smtp') { + if ($this->config->get('mail.default') !== 'smtp') { throw new DisplayException('This feature is only available if SMTP is the selected email driver for the Panel.'); } diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.php index 254a72f8c..1d6db6569 100644 --- a/app/Http/Controllers/Admin/UserController.php +++ b/app/Http/Controllers/Admin/UserController.php @@ -19,6 +19,7 @@ use Pterodactyl\Traits\Helpers\AvailableLanguages; use Pterodactyl\Services\Users\UserCreationService; use Pterodactyl\Services\Users\UserDeletionService; use Pterodactyl\Http\Requests\Admin\UserFormRequest; +use Pterodactyl\Http\Requests\Admin\NewUserFormRequest; use Pterodactyl\Contracts\Repository\UserRepositoryInterface; class UserController extends Controller @@ -103,7 +104,7 @@ class UserController extends Controller * @throws \Exception * @throws \Throwable */ - public function store(UserFormRequest $request): RedirectResponse + public function store(NewUserFormRequest $request): RedirectResponse { $user = $this->creationService->handle($request->normalize()); $this->alert->success($this->translator->get('admin/user.notices.account_created'))->flash(); diff --git a/app/Http/Requests/Admin/NewUserFormRequest.php b/app/Http/Requests/Admin/NewUserFormRequest.php new file mode 100644 index 000000000..d8c199380 --- /dev/null +++ b/app/Http/Requests/Admin/NewUserFormRequest.php @@ -0,0 +1,28 @@ +only([ + 'email', + 'username', + 'name_first', + 'name_last', + 'password', + 'language', + 'root_admin', + ])->toArray(); + } +} diff --git a/app/Providers/SettingsServiceProvider.php b/app/Providers/SettingsServiceProvider.php index 5508ee0fb..9c8a7445e 100644 --- a/app/Providers/SettingsServiceProvider.php +++ b/app/Providers/SettingsServiceProvider.php @@ -61,7 +61,7 @@ class SettingsServiceProvider extends ServiceProvider { // Only set the email driver settings from the database if we // are configured using SMTP as the driver. - if ($config->get('mail.driver') === 'smtp') { + if ($config->get('mail.default') === 'smtp') { $this->keys = array_merge($this->keys, $this->emailKeys); } diff --git a/resources/views/admin/settings/mail.blade.php b/resources/views/admin/settings/mail.blade.php index 580271e02..b13446995 100644 --- a/resources/views/admin/settings/mail.blade.php +++ b/resources/views/admin/settings/mail.blade.php @@ -38,14 +38,14 @@
- +

Enter the SMTP server address that mail should be sent through.

- +

Enter the SMTP server port that mail should be sent through.

@@ -53,7 +53,7 @@
@php - $encryption = old('mail:encryption', config('mail.encryption')); + $encryption = old('mail:encryption', config('mail.mailers.smtp.encryption')); @endphp +

The username to use when connecting to the SMTP server.