Simplify and restrict api keys

This commit is contained in:
Lance Pioch 2024-04-12 13:05:04 -04:00
parent 05e9f12dc4
commit 99693367d3
2 changed files with 4 additions and 0 deletions

View File

@ -46,6 +46,7 @@ class ApiKeyResource extends Resource
Forms\Components\Hidden::make('token')->default(encrypt(str_random(ApiKey::KEY_LENGTH))), Forms\Components\Hidden::make('token')->default(encrypt(str_random(ApiKey::KEY_LENGTH))),
Forms\Components\Select::make('user_id') Forms\Components\Select::make('user_id')
->hidden()
->searchable() ->searchable()
->preload() ->preload()
->relationship('user', 'username') ->relationship('user', 'username')
@ -66,6 +67,7 @@ class ApiKeyResource extends Resource
->filter(fn ($value, $key) => $key <= ApiKey::TYPE_APPLICATION || $apiKey->key_type === $key) ->filter(fn ($value, $key) => $key <= ApiKey::TYPE_APPLICATION || $apiKey->key_type === $key)
->all(); ->all();
}) })
->hidden()
->selectablePlaceholder(false) ->selectablePlaceholder(false)
->required() ->required()
->default(ApiKey::TYPE_APPLICATION), ->default(ApiKey::TYPE_APPLICATION),

View File

@ -9,4 +9,6 @@ use Filament\Resources\Pages\CreateRecord;
class CreateApiKey extends CreateRecord class CreateApiKey extends CreateRecord
{ {
protected static string $resource = ApiKeyResource::class; protected static string $resource = ApiKeyResource::class;
protected ?string $heading = 'Create Application API Key';
} }