snipe-it/app/Http/Livewire/PersonalAccessTokens.php
spencerrlongg af144a5184 cleanup
2023-11-15 16:55:21 -06:00

41 lines
920 B
PHP

<?php
namespace App\Http\Livewire;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Log;
use Illuminate\View\View;
use Livewire\Component;
class PersonalAccessTokens extends Component
{
public $name;
public function render()
{
return view('livewire.personal-access-tokens', [
'tokens' => Auth::user()->tokens,
]);
}
public function rules(): array
{
return [
'name' => 'required|string|max:255',
'scopes' => 'nullable|array',
];
}
public function createToken(): void
{
Auth::user()->createToken($this->name);
}
public function deleteToken($tokenId): void
{
Log::info('poo');
//this needs safety (though the scope of auth::user might kind of do it...)
//seems like it does, test more
Auth::user()->tokens()->find($tokenId)->delete();
}
}