From 5b3ae995e690fd56a3a41049fd5da408706c5c01 Mon Sep 17 00:00:00 2001 From: Boy132 Date: Fri, 6 Dec 2024 22:31:58 +0100 Subject: [PATCH] Show full client api key after creation (#771) * show notification when api key is created * remove hardcoded redirect url --- .../Resources/UserResource/Pages/EditProfile.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/Filament/Resources/UserResource/Pages/EditProfile.php b/app/Filament/Resources/UserResource/Pages/EditProfile.php index 7c39f5c66..4b3c7e3d4 100644 --- a/app/Filament/Resources/UserResource/Pages/EditProfile.php +++ b/app/Filament/Resources/UserResource/Pages/EditProfile.php @@ -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(); }), ]),