Show full client api key after creation (#771)
* show notification when api key is created * remove hardcoded redirect url
This commit is contained in:
parent
2a34795ab1
commit
5b3ae995e6
@ -272,16 +272,25 @@ class EditProfile extends BaseEditProfile
|
|||||||
])->headerActions([
|
])->headerActions([
|
||||||
Action::make('Create')
|
Action::make('Create')
|
||||||
->disabled(fn (Get $get) => $get('description') === null)
|
->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) {
|
->action(function (Get $get, Action $action, User $user) {
|
||||||
$token = $user->createToken(
|
$token = $user->createToken(
|
||||||
$get('description'),
|
$get('description'),
|
||||||
$get('allowed_ips'),
|
$get('allowed_ips'),
|
||||||
);
|
);
|
||||||
|
|
||||||
Activity::event('user:api-key.create')
|
Activity::event('user:api-key.create')
|
||||||
->subject($token->accessToken)
|
->subject($token->accessToken)
|
||||||
->property('identifier', $token->accessToken->identifier)
|
->property('identifier', $token->accessToken->identifier)
|
||||||
->log();
|
->log();
|
||||||
|
|
||||||
|
Notification::make()
|
||||||
|
->title('API Key created')
|
||||||
|
->body($token->accessToken->identifier . $token->plainTextToken)
|
||||||
|
->persistent()
|
||||||
|
->success()
|
||||||
|
->send();
|
||||||
|
|
||||||
$action->success();
|
$action->success();
|
||||||
}),
|
}),
|
||||||
]),
|
]),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user