Skip to content

Commit e49ba65

Browse files
authored
Fix config key names (pterodactyl#4464)
1 parent 7266c66 commit e49ba65

File tree

7 files changed

+47
-17
lines changed

7 files changed

+47
-17
lines changed

app/Console/Commands/Environment/EmailSettingsCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function handle()
4949
'mandrill' => 'Mandrill Transactional Email',
5050
'postmark' => 'Postmark Transactional Email',
5151
],
52-
$this->config->get('mail.driver', 'smtp')
52+
$this->config->get('mail.default', 'smtp')
5353
);
5454

5555
$method = 'setup' . studly_case($this->variables['MAIL_DRIVER']) . 'DriverVariables';
@@ -86,17 +86,17 @@ private function setupSmtpDriverVariables()
8686
{
8787
$this->variables['MAIL_HOST'] = $this->option('host') ?? $this->ask(
8888
trans('command/messages.environment.mail.ask_smtp_host'),
89-
$this->config->get('mail.host')
89+
$this->config->get('mail.mailers.smtp.host')
9090
);
9191

9292
$this->variables['MAIL_PORT'] = $this->option('port') ?? $this->ask(
9393
trans('command/messages.environment.mail.ask_smtp_port'),
94-
$this->config->get('mail.port')
94+
$this->config->get('mail.mailers.smtp.port')
9595
);
9696

9797
$this->variables['MAIL_USERNAME'] = $this->option('username') ?? $this->ask(
9898
trans('command/messages.environment.mail.ask_smtp_username'),
99-
$this->config->get('mail.username')
99+
$this->config->get('mail.mailers.smtp.username')
100100
);
101101

102102
$this->variables['MAIL_PASSWORD'] = $this->option('password') ?? $this->secret(

app/Console/Commands/InfoCommand.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,16 @@ public function handle()
5858
['Username', $this->config->get("database.connections.$driver.username")],
5959
], 'compact');
6060

61+
// TODO: Update this to handle other mail drivers
6162
$this->output->title('Email Configuration');
6263
$this->table([], [
63-
['Driver', $this->config->get('mail.driver')],
64-
['Host', $this->config->get('mail.host')],
65-
['Port', $this->config->get('mail.port')],
66-
['Username', $this->config->get('mail.username')],
64+
['Driver', $this->config->get('mail.default')],
65+
['Host', $this->config->get('mail.mailers.smtp.host')],
66+
['Port', $this->config->get('mail.mailers.smtp.port')],
67+
['Username', $this->config->get('mail.mailers.smtp.username')],
6768
['From Address', $this->config->get('mail.from.address')],
6869
['From Name', $this->config->get('mail.from.name')],
69-
['Encryption', $this->config->get('mail.encryption')],
70+
['Encryption', $this->config->get('mail.mailers.smtp.encryption')],
7071
], 'compact');
7172
}
7273

app/Http/Controllers/Admin/Settings/MailController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function __construct(
3939
public function index(): View
4040
{
4141
return $this->view->make('admin.settings.mail', [
42-
'disabled' => $this->config->get('mail.driver') !== 'smtp',
42+
'disabled' => $this->config->get('mail.default') !== 'smtp',
4343
]);
4444
}
4545

@@ -52,7 +52,7 @@ public function index(): View
5252
*/
5353
public function update(MailSettingsFormRequest $request): Response
5454
{
55-
if ($this->config->get('mail.driver') !== 'smtp') {
55+
if ($this->config->get('mail.default') !== 'smtp') {
5656
throw new DisplayException('This feature is only available if SMTP is the selected email driver for the Panel.');
5757
}
5858

app/Http/Controllers/Admin/UserController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Pterodactyl\Services\Users\UserCreationService;
2020
use Pterodactyl\Services\Users\UserDeletionService;
2121
use Pterodactyl\Http\Requests\Admin\UserFormRequest;
22+
use Pterodactyl\Http\Requests\Admin\NewUserFormRequest;
2223
use Pterodactyl\Contracts\Repository\UserRepositoryInterface;
2324

2425
class UserController extends Controller
@@ -103,7 +104,7 @@ public function delete(Request $request, User $user): RedirectResponse
103104
* @throws \Exception
104105
* @throws \Throwable
105106
*/
106-
public function store(UserFormRequest $request): RedirectResponse
107+
public function store(NewUserFormRequest $request): RedirectResponse
107108
{
108109
$user = $this->creationService->handle($request->normalize());
109110
$this->alert->success($this->translator->get('admin/user.notices.account_created'))->flash();
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace Pterodactyl\Http\Requests\Admin;
4+
5+
use Pterodactyl\Models\User;
6+
use Illuminate\Support\Collection;
7+
8+
class NewUserFormRequest extends AdminFormRequest
9+
{
10+
/**
11+
* Rules to apply to requests for updating or creating a user
12+
* in the Admin CP.
13+
*/
14+
public function rules(): array
15+
{
16+
return Collection::make(
17+
User::getRules()
18+
)->only([
19+
'email',
20+
'username',
21+
'name_first',
22+
'name_last',
23+
'password',
24+
'language',
25+
'root_admin',
26+
])->toArray();
27+
}
28+
}

app/Providers/SettingsServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function boot(ConfigRepository $config, Encrypter $encrypter, Log $log, S
6161
{
6262
// Only set the email driver settings from the database if we
6363
// are configured using SMTP as the driver.
64-
if ($config->get('mail.driver') === 'smtp') {
64+
if ($config->get('mail.default') === 'smtp') {
6565
$this->keys = array_merge($this->keys, $this->emailKeys);
6666
}
6767

resources/views/admin/settings/mail.blade.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,22 @@
3838
<div class="form-group col-md-6">
3939
<label class="control-label">SMTP Host</label>
4040
<div>
41-
<input required type="text" class="form-control" name="mail:host" value="{{ old('mail:host', config('mail.host')) }}" />
41+
<input required type="text" class="form-control" name="mail:host" value="{{ old('mail:host', config('mail.mailers.smtp.host')) }}" />
4242
<p class="text-muted small">Enter the SMTP server address that mail should be sent through.</p>
4343
</div>
4444
</div>
4545
<div class="form-group col-md-2">
4646
<label class="control-label">SMTP Port</label>
4747
<div>
48-
<input required type="number" class="form-control" name="mail:port" value="{{ old('mail:port', config('mail.port')) }}" />
48+
<input required type="number" class="form-control" name="mail:port" value="{{ old('mail:port', config('mail.mailers.smtp.port')) }}" />
4949
<p class="text-muted small">Enter the SMTP server port that mail should be sent through.</p>
5050
</div>
5151
</div>
5252
<div class="form-group col-md-4">
5353
<label class="control-label">Encryption</label>
5454
<div>
5555
@php
56-
$encryption = old('mail:encryption', config('mail.encryption'));
56+
$encryption = old('mail:encryption', config('mail.mailers.smtp.encryption'));
5757
@endphp
5858
<select name="mail:encryption" class="form-control">
5959
<option value="" @if($encryption === '') selected @endif>None</option>
@@ -66,7 +66,7 @@
6666
<div class="form-group col-md-6">
6767
<label class="control-label">Username <span class="field-optional"></span></label>
6868
<div>
69-
<input type="text" class="form-control" name="mail:username" value="{{ old('mail:username', config('mail.username')) }}" />
69+
<input type="text" class="form-control" name="mail:username" value="{{ old('mail:username', config('mail.mailers.smtp.username')) }}" />
7070
<p class="text-muted small">The username to use when connecting to the SMTP server.</p>
7171
</div>
7272
</div>

0 commit comments

Comments
 (0)