feat(api-tokens): roll a token to replace its secret

Keep the description, permissions, scopes, and expiry. Move the row actions into a dropdown menu and measure the dropdown panel after it is shown, so menus at the right edge stay on screen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Andras Bacsai
2026-10-30 13:06:43 +01:00
co-authored by Claude Opus 5.5
parent edee5ccfd6
commit 263eab5d27
5 changed files with 82 additions and 20 deletions
+1 -7
View File
@@ -23,7 +23,6 @@ use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\Str;
use Laravel\Fortify\Contracts\PasskeyUser;
use Laravel\Fortify\PasskeyAuthenticatable;
use Laravel\Fortify\TwoFactorAuthenticatable;
@@ -269,12 +268,7 @@ class User extends Authenticatable implements PasskeyUser, SendsEmail
public function createToken(string $name, array $abilities = ['read'], ?DateTimeInterface $expiresAt = null, ?int $teamId = null)
{
$plainTextToken = sprintf(
'%s%s%s',
config('sanctum.token_prefix', ''),
$tokenEntropy = Str::random(40),
hash('crc32b', $tokenEntropy)
);
$plainTextToken = PersonalAccessToken::generateSecret();
$token = $this->tokens()->create([
'name' => $name,