mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-17 11:04:07 -08:00
47 lines
1 KiB
PHP
47 lines
1 KiB
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 $newTokenString;
|
|
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
|
|
{
|
|
$newToken = Auth::user()->createToken($this->name);
|
|
|
|
$this->newTokenString = $newToken->accessToken;
|
|
|
|
Log::alert($newToken);
|
|
}
|
|
|
|
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();
|
|
}
|
|
}
|