more updates
Some checks failed
🧪✨ Tests Workflow / 📝 ✨ Code Lint (push) Successful in 2m25s
🧪✨ Tests Workflow / 🛡️ 🔒 Library Audit (push) Successful in 2m35s
🧪✨ Tests Workflow / 🧪 ✨ Database Migrations (push) Failing after 2m45s
🧪✨ Tests Workflow / 🛡️ 🔒 License Check (push) Successful in 2m36s
🧪✨ Tests Workflow / 🐙 🔍 Code Sniffer (push) Failing after 2m25s
🧪✨ Tests Workflow / 🧪 ✅ Unit Tests (push) Failing after 1m10s

This commit is contained in:
2026-01-02 13:57:41 -05:00
parent d0cee7b48f
commit b5b6caa400
20 changed files with 1251 additions and 872 deletions

View File

@@ -4,45 +4,54 @@ declare(strict_types=1);
namespace Siteworxpro\App\Cli\Commands\OAuth;
use Ahc\Cli\IO\Interactor;
use Siteworxpro\App\Cli\ClimateOutput;
use Siteworxpro\App\CommandBus\Commands\CreateClient as CreateClientCommand;
use Siteworxpro\App\CommandBus\Exceptions\CommandHandlerException;
use Siteworxpro\App\OAuth\Entities\Client;
use Siteworxpro\App\Services\Facades\CommandBus;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\ChoiceQuestion;
use Symfony\Component\Console\Question\Question;
#[AsCommand(name: 'oauth:client:create', description: 'Create a new OAuth client.')]
class CreateClient extends \Siteworxpro\App\Cli\Commands\Command
{
public function __construct()
public function __invoke($input, $output): int
{
parent::__construct('oauth:client:create', 'Create a new OAuth client.');
}
$question = new Question('Enter client name: ');
$clientName = $this->helper->ask($input, $output, $question);
public function execute(): int
{
$interactor = new Interactor();
$clientName = $interactor->prompt('Enter client name');
$clientDescription = $interactor->prompt('Enter client description (optional)', '');
$clientGrantsString = $interactor->prompt(
'Enter client grants (comma separated, e.g. "authorization_code,refresh_token")',
false
);
$question = new Question('Enter client description (optional): ', '');
$clientDescription = $this->helper->ask($input, $output, $question);
$grants = explode(',', $clientGrantsString);
$question = new ChoiceQuestion('Enter client grants', [
'authorization_code',
'client_credentials',
'refresh_token',
'password',
], 0);
$question->setMultiselect(true);
$grants = $this->helper->ask($input, $output, $question);
$command = new CreateClientCommand($clientName, $grants, $clientDescription);
try {
/** @var Client $client */
$client = CommandBus::handle($command);
$this->climate->green('OAuth client created successfully');
$this->climate->info('Client ID: ' . $client->client_id);
$this->climate->info('Client Secret: ' . $client->client_secret)->br(2);
$output->green('OAuth client created successfully');
$output->info('Client ID: ' . $client->client_id);
$output->info('Client Secret: ' . $client->client_secret)->br(2);
} catch (CommandHandlerException $exception) {
$this->climate->error($exception->getMessage());
$output->error($exception->getMessage());
return 1;
return Command::FAILURE;
}
return 0;
return Command::SUCCESS;
}
}