Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix config key names #4464

Merged
merged 3 commits into from
Oct 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions app/Console/Commands/Environment/EmailSettingsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function handle()
'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';
Expand Down Expand Up @@ -86,17 +86,17 @@ private function setupSmtpDriverVariables()
{
$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(
Expand Down
11 changes: 6 additions & 5 deletions app/Console/Commands/InfoCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,16 @@ public function handle()
['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');
}

Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/Admin/Settings/MailController.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function __construct(
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',
]);
}

Expand All @@ -52,7 +52,7 @@ public function index(): View
*/
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.');
}

Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/Admin/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
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
Expand Down Expand Up @@ -103,7 +104,7 @@ public function delete(Request $request, User $user): RedirectResponse
* @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();
Expand Down
28 changes: 28 additions & 0 deletions app/Http/Requests/Admin/NewUserFormRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace Pterodactyl\Http\Requests\Admin;

use Pterodactyl\Models\User;
use Illuminate\Support\Collection;

class NewUserFormRequest extends AdminFormRequest
{
/**
* Rules to apply to requests for updating or creating a user
* in the Admin CP.
*/
public function rules(): array
{
return Collection::make(
User::getRules()
)->only([
'email',
'username',
'name_first',
'name_last',
'password',
'language',
'root_admin',
])->toArray();
}
}
2 changes: 1 addition & 1 deletion app/Providers/SettingsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function boot(ConfigRepository $config, Encrypter $encrypter, Log $log, S
{
// 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);
}

Expand Down
8 changes: 4 additions & 4 deletions resources/views/admin/settings/mail.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,22 @@
<div class="form-group col-md-6">
<label class="control-label">SMTP Host</label>
<div>
<input required type="text" class="form-control" name="mail:host" value="{{ old('mail:host', config('mail.host')) }}" />
<input required type="text" class="form-control" name="mail:host" value="{{ old('mail:host', config('mail.mailers.smtp.host')) }}" />
<p class="text-muted small">Enter the SMTP server address that mail should be sent through.</p>
</div>
</div>
<div class="form-group col-md-2">
<label class="control-label">SMTP Port</label>
<div>
<input required type="number" class="form-control" name="mail:port" value="{{ old('mail:port', config('mail.port')) }}" />
<input required type="number" class="form-control" name="mail:port" value="{{ old('mail:port', config('mail.mailers.smtp.port')) }}" />
<p class="text-muted small">Enter the SMTP server port that mail should be sent through.</p>
</div>
</div>
<div class="form-group col-md-4">
<label class="control-label">Encryption</label>
<div>
@php
$encryption = old('mail:encryption', config('mail.encryption'));
$encryption = old('mail:encryption', config('mail.mailers.smtp.encryption'));
@endphp
<select name="mail:encryption" class="form-control">
<option value="" @if($encryption === '') selected @endif>None</option>
Expand All @@ -66,7 +66,7 @@
<div class="form-group col-md-6">
<label class="control-label">Username <span class="field-optional"></span></label>
<div>
<input type="text" class="form-control" name="mail:username" value="{{ old('mail:username', config('mail.username')) }}" />
<input type="text" class="form-control" name="mail:username" value="{{ old('mail:username', config('mail.mailers.smtp.username')) }}" />
<p class="text-muted small">The username to use when connecting to the SMTP server.</p>
</div>
</div>
Expand Down