mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-12 15:53:46 -04:00
fix(api-tokens): open the tokens page when a token has unreadable scopes
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
989c2238f8
commit
879bd5c42a
@@ -0,0 +1,4 @@
|
||||
---
|
||||
type: fixed
|
||||
---
|
||||
Crashed the `Keys & Tokens` > `API Tokens` page with a 500 error for a token with scopes stored in an unexpected format
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Livewire\Forms;
|
||||
|
||||
use App\Services\Access\Grant;
|
||||
use Laravel\Sanctum\PersonalAccessToken;
|
||||
use Livewire\Form;
|
||||
|
||||
@@ -55,7 +56,7 @@ class ApiTokenForm extends Form
|
||||
'description' => $token->name,
|
||||
'permissions' => $permissions,
|
||||
'scopeMode' => $token->scopes === null ? 'team' : 'selected',
|
||||
'selectedScopes' => collect($token->scopes ?? [])->map(fn (array $scope) => "{$scope['scope']}:{$scope['uuid']}")->values()->all(),
|
||||
'selectedScopes' => array_map(fn (Grant $scope) => "{$scope->scope->value}:{$scope->uuid}", Grant::listFrom($token->scopes)),
|
||||
'expiresInDays' => self::KEEP_EXPIRY,
|
||||
'keepLabel' => 'Keep current ('.($token->expires_at?->isPast() ? 'expired '.$currentExpiry : $currentExpiry).')',
|
||||
];
|
||||
|
||||
@@ -174,7 +174,7 @@ class ApiTokens extends Component
|
||||
'search' => Str::lower(collect([$token->name, ...($token->abilities ?? [])])
|
||||
->merge($token->scopes === null
|
||||
? ['All resources in the team']
|
||||
: collect($token->scopes)->map(fn ($scope) => $scopeLabels[($scope['scope'] ?? '').':'.($scope['uuid'] ?? '')] ?? null)->filter())
|
||||
: collect(Grant::listFrom($token->scopes))->map(fn (Grant $scope) => $scopeLabels[$scope->scope->value.':'.$scope->uuid] ?? null)->filter())
|
||||
->join(' ')),
|
||||
])->values()->all();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user