You've already forked php-auth
generated from siteworxpro/Php-Template
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
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:
46
src/Cli/Commands/OAuth/AddScope.php
Normal file
46
src/Cli/Commands/OAuth/AddScope.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Siteworxpro\App\Cli\Commands\OAuth;
|
||||
|
||||
use Siteworxpro\App\Cli\Commands\Command;
|
||||
use Siteworxpro\App\OAuth\Entities\Scope;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
use Symfony\Component\Console\Command\Command as SympCommand;
|
||||
use Symfony\Component\Console\Input\ArgvInput;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
|
||||
#[AsCommand('oauth:scope:add', 'Add a new OAuth scope')]
|
||||
class AddScope extends Command
|
||||
{
|
||||
protected function configure(): void
|
||||
{
|
||||
$this
|
||||
->addArgument('name', InputArgument::REQUIRED, 'The name of the scope')
|
||||
->addArgument('description', InputArgument::OPTIONAL, 'The description of the scope');
|
||||
}
|
||||
|
||||
public function __invoke(ArgvInput | InputInterface $input, $output): int
|
||||
{
|
||||
$name = $input->getArgument('name');
|
||||
$description = $input->getArgument('description') ?? '';
|
||||
|
||||
$scope = Scope::where('name', $name)->first();
|
||||
if ($scope) {
|
||||
$output->error("Scope with name '$name' already exists.");
|
||||
|
||||
return SympCommand::FAILURE;
|
||||
}
|
||||
|
||||
$scope = new Scope();
|
||||
$scope->name = $name;
|
||||
$scope->description = $description;
|
||||
$scope->save();
|
||||
|
||||
$output->green("Scope '$name' added successfully.");
|
||||
|
||||
return SympCommand::SUCCESS;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user