|
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
|
|
namespace SixShop\Auth\Command;
|
|
namespace SixShop\Auth\Command;
|
|
|
|
|
|
|
|
use think\console\Command;
|
|
use think\console\Command;
|
|
|
|
|
+use think\console\input\Option;
|
|
|
use think\helper\Str;
|
|
use think\helper\Str;
|
|
|
|
|
|
|
|
class JWTGenerateSecretCommand extends Command
|
|
class JWTGenerateSecretCommand extends Command
|
|
@@ -11,7 +12,8 @@ class JWTGenerateSecretCommand extends Command
|
|
|
public function configure(): void
|
|
public function configure(): void
|
|
|
{
|
|
{
|
|
|
$this->setName('jwt:secret')
|
|
$this->setName('jwt:secret')
|
|
|
- ->setDescription('Set the JWTAuth secret key used to sign the tokens');
|
|
|
|
|
|
|
+ ->setDescription('Set the JWTAuth secret key used to sign the tokens')
|
|
|
|
|
+ ->addOption('force', 'f', Option::VALUE_NONE, 'Force the operation to run when in production');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function handle(): void
|
|
public function handle(): void
|
|
@@ -27,7 +29,7 @@ class JWTGenerateSecretCommand extends Command
|
|
|
file_put_contents($path, PHP_EOL . "JWT_SECRET=$key" . PHP_EOL, FILE_APPEND);
|
|
file_put_contents($path, PHP_EOL . "JWT_SECRET=$key" . PHP_EOL, FILE_APPEND);
|
|
|
} else {
|
|
} else {
|
|
|
|
|
|
|
|
- if ($this->isConfirmed() === false) {
|
|
|
|
|
|
|
+ if ($this->input->getOption('force') === false && $this->isConfirmed() === false) {
|
|
|
$this->output->writeln('Phew... No changes were made to your secret key.');
|
|
$this->output->writeln('Phew... No changes were made to your secret key.');
|
|
|
|
|
|
|
|
return;
|
|
return;
|