lolispace-applications/app/Livewire/RegistrationToken.php

59 lines
1.1 KiB
PHP

<?php
namespace App\Livewire;
use App\Services\SynapseService;
use Livewire\Component;
use Illuminate\Support\Facades\Http;
class RegistrationToken extends Component
{
public $tokens = [];
public $registrationToken;
protected SynapseService $synapseService;
public function boot(SynapseService $synapseService)
{
$this->synapseService = $synapseService;
}
public function mount()
{
$this->fetchTokens();
}
public function fetchTokens()
{
$this->tokens = $this->synapseService->fetchTokens();
}
public function revokeToken(string $token)
{
if ($this->synapseService->revokeToken($token)) {
$this->fetchTokens();
}
}
public function createToken()
{
$this->registrationToken = $this->synapseService->createRegistrationToken();
// Open modal
$this->modal('registration-token')->show();
}
public function resetToken()
{
$this->registrationToken = null;
$this->fetchTokens();
}
public function render()
{
return view('livewire.registration-token');
}
}