php artisan app:generate-register-token

This commit is contained in:
2026-03-25 00:14:58 +01:00
parent 7bf444123d
commit 91554516d3

View File

@@ -0,0 +1,35 @@
<?php
namespace App\Console\Commands;
use App\Models\RegisterToken;
use Illuminate\Console\Attributes\Description;
use Illuminate\Console\Attributes\Signature;
use Illuminate\Console\Command;
use Nette\Utils\Random;
#[Signature('app:generate-register-token')]
#[Description('Generate a register token for the internal authentication platform.')]
class GenerateRegisterToken extends Command
{
/**
* Execute the console command.
*/
public function handle()
{
$newToken = Random::generate(12, "0-9A-Z");
try {
$rt = new RegisterToken;
$rt->token = $newToken;
$rt->save();
} catch (\ErrorException $e) {
$this->error($e->getMessage());
return 1;
}
$this->info("Register token generated: \n" . $newToken);
return 0;
}
}