add admin command
This commit is contained in:
parent
4462879b7d
commit
fee174ec05
7 changed files with 120 additions and 0 deletions
36
backend/app/Console/Commands/EnsureInitialAdminCommand.php
Normal file
36
backend/app/Console/Commands/EnsureInitialAdminCommand.php
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\User\InitialAdminCredentialsProvider;
|
||||
use App\User\UseCases\EnsureInitialAdmin\EnsureInitialAdmin;
|
||||
use App\User\UseCases\EnsureInitialAdmin\EnsureInitialAdminRequest;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class EnsureInitialAdminCommand extends Command
|
||||
{
|
||||
protected $signature = 'rabbi-gerzi:ensure-initial-admin';
|
||||
|
||||
protected $description = 'Create the configured initial admin if missing';
|
||||
|
||||
public function __construct(
|
||||
private EnsureInitialAdmin $ensureInitialAdmin,
|
||||
private InitialAdminCredentialsProvider $credentialsProvider,
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function handle(): int
|
||||
{
|
||||
$credentials = $this->credentialsProvider->getCredentials();
|
||||
|
||||
$this->ensureInitialAdmin->execute(new EnsureInitialAdminRequest(
|
||||
email: $credentials->getEmail(),
|
||||
password: $credentials->getPassword(),
|
||||
));
|
||||
|
||||
$this->info('initial admin is ready');
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue