diff --git a/src/flextype/core/Console/Commands/Utils/GenerateTokenCommand.php b/src/flextype/core/Console/Commands/Utils/GenerateTokenCommand.php index c835300c..d44ce832 100644 --- a/src/flextype/core/Console/Commands/Utils/GenerateTokenCommand.php +++ b/src/flextype/core/Console/Commands/Utils/GenerateTokenCommand.php @@ -20,6 +20,8 @@ use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputArgument; +use function Thermage\div; +use function Thermage\renderToString; class GenerateTokenCommand extends Command { @@ -32,7 +34,13 @@ class GenerateTokenCommand extends Command protected function execute(InputInterface $input, OutputInterface $output): int { - $output->writeln(generateToken($input->getArgument('length') ?? 16)); + $output->write( + renderToString( + div('Success: Token [b]' . generateToken($input->getArgument('length') ?? 16) . '[/b] generated.', + 'bg-success px-2 py-1') + ) + ); + return Command::SUCCESS; } } \ No newline at end of file diff --git a/src/flextype/core/Console/Commands/Utils/GenerateTokenHashCommand.php b/src/flextype/core/Console/Commands/Utils/GenerateTokenHashCommand.php index a17c37b1..727830b6 100644 --- a/src/flextype/core/Console/Commands/Utils/GenerateTokenHashCommand.php +++ b/src/flextype/core/Console/Commands/Utils/GenerateTokenHashCommand.php @@ -20,6 +20,8 @@ use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputArgument; +use function Thermage\div; +use function Thermage\renderToString; class GenerateTokenHashCommand extends Command { @@ -27,12 +29,20 @@ class GenerateTokenHashCommand extends Command { $this->setName('utils:generate-token-hash'); $this->setDescription('Generate token hash.'); - $this->addArgument('token', InputArgument::REQUIRED, 'Token string.'); + $this->addArgument('token', InputArgument::OPTIONAL, 'Token string.'); } protected function execute(InputInterface $input, OutputInterface $output): int { - $output->writeln(generateTokenHash($input->getArgument('token'))); + $token = $input->getArgument('token') ?? generateToken(); + + $output->write( + renderToString( + div('Success: Hash [b]' . generateTokenHash($token) . '[/b] for token [b]' . $token . '[/b] generated.', + 'bg-success px-2 py-1') + ) + ); + return Command::SUCCESS; } } \ No newline at end of file diff --git a/src/flextype/core/Console/Commands/Utils/VerifyTokenHashCommand.php b/src/flextype/core/Console/Commands/Utils/VerifyTokenHashCommand.php index 9e9b14f4..b38adfb3 100644 --- a/src/flextype/core/Console/Commands/Utils/VerifyTokenHashCommand.php +++ b/src/flextype/core/Console/Commands/Utils/VerifyTokenHashCommand.php @@ -21,6 +21,8 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Style\SymfonyStyle; +use function Thermage\div; +use function Thermage\renderToString; class VerifyTokenHashCommand extends Command { @@ -34,13 +36,23 @@ class VerifyTokenHashCommand extends Command protected function execute(InputInterface $input, OutputInterface $output): int { - $io = new SymfonyStyle($input, $output); - if (verrifyTokenHash($input->getArgument('token'), $input->getArgument('token-hash') )) { - $io->success('Token ' . $input->getArgument('token') . ' is verified'); + $output->write( + renderToString( + div('Success: Token [b]' . $input->getArgument('token') . ' is verified', + 'bg-success px-2 py-1') + ) + ); + return Command::SUCCESS; } else { - $io->error('Token ' . $input->getArgument('token') . ' isn\'t verified'); + $output->write( + renderToString( + div('Failure: Token [b]' . $input->getArgument('token') . ' isn\'t verified', + 'bg-success px-2 py-1') + ) + ); + return Command::FAILURE; } }