Skip to content

Commit 21cd068

Browse files
committed
Added giant warning message if you attempt to change an encryption key once one has been set.
1 parent 80994dc commit 21cd068

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
1515

1616
### Added
1717
* Added ability for end users to change the name of their server through the UI. This option is only open to the server owner or an admin.
18+
* Added giant warning message if you attempt to change an encryption key once one has been set.
1819

1920
### Changed
2021
* Panel now throws proper 504: Gateway Timeout errors on server listing when daemon is offline.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace Pterodactyl\Console\Commands\Overrides;
4+
5+
use Illuminate\Foundation\Console\KeyGenerateCommand as BaseKeyGenerateCommand;
6+
7+
class KeyGenerateCommand extends BaseKeyGenerateCommand
8+
{
9+
/**
10+
* Override the default Laravel key generation command to throw a warning to the user
11+
* if it appears that they have already generated an application encryption key.
12+
*/
13+
public function handle()
14+
{
15+
if (! empty(config('app.key')) && $this->input->isInteractive()) {
16+
$this->output->warning(trans('command/messages.key.warning'));
17+
if (! $this->confirm(trans('command/messages.key.confirm'))) {
18+
return;
19+
}
20+
21+
if (! $this->confirm(trans('command/messages.key.final_confirm'))) {
22+
return;
23+
}
24+
}
25+
26+
parent::handle();
27+
}
28+
}

resources/lang/en/command/messages.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
<?php
22

33
return [
4+
'key' => [
5+
'warning' => 'It appears you have already configured an application encryption key. Continuing with this process with overwrite that key and cause data corruption for any existing encrypted data. DO NOT CONTINUE UNLESS YOU KNOW WHAT YOU ARE DOING.',
6+
'confirm' => 'I understand the consequences of performing this command and accept all responsibility for the loss of encrypted data.',
7+
'final_confirm' => 'Are you sure you wish to continue? Changing the application encryption key WILL CAUSE DATA LOSS.',
8+
],
49
'location' => [
510
'no_location_found' => 'Could not locate a record matching the provided short code.',
611
'ask_short' => 'Location Short Code',

0 commit comments

Comments
 (0)