Show full client api key after creation (#771)

* show notification when api key is created

* remove hardcoded redirect url
This commit is contained in:
Boy132 2024-12-06 22:31:58 +01:00 committed by GitHub
parent 2a34795ab1
commit 5b3ae995e6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -272,16 +272,25 @@ class EditProfile extends BaseEditProfile
])->headerActions([
Action::make('Create')
->disabled(fn (Get $get) => $get('description') === null)
->successRedirectUrl(route('filament.admin.auth.profile', ['tab' => '-api-keys-tab']))
->successRedirectUrl(self::getUrl(['tab' => '-api-keys-tab']))
->action(function (Get $get, Action $action, User $user) {
$token = $user->createToken(
$get('description'),
$get('allowed_ips'),
);
Activity::event('user:api-key.create')
->subject($token->accessToken)
->property('identifier', $token->accessToken->identifier)
->log();
Notification::make()
->title('API Key created')
->body($token->accessToken->identifier . $token->plainTextToken)
->persistent()
->success()
->send();
$action->success();
}),
]),