From 67ad24af084c031a70875f75ebe1e0ca7bc3fde5 Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 28 Jun 2022 23:13:25 -0700 Subject: [PATCH] Return token ID in cli Signed-off-by: snipe --- app/Console/Commands/GeneratePersonalAccessToken.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/Console/Commands/GeneratePersonalAccessToken.php b/app/Console/Commands/GeneratePersonalAccessToken.php index 7179cfeb89..66fc03e27b 100644 --- a/app/Console/Commands/GeneratePersonalAccessToken.php +++ b/app/Console/Commands/GeneratePersonalAccessToken.php @@ -7,6 +7,7 @@ use Illuminate\Console\Command; use App\Models\User; use Laravel\Passport\TokenRepository; use Illuminate\Contracts\Validation\Factory as ValidationFactory; +use DB; class GeneratePersonalAccessToken extends Command { @@ -71,7 +72,10 @@ class GeneratePersonalAccessToken extends Command if ($this->option('key-only')) { $this->info($user->createToken($accessTokenName)->accessToken); } else { + $token = DB::table('oauth_access_tokens')->where('user_id', '=', $user->id)->where('name','=',$accessTokenName)->orderBy('created_at', 'desc')->first(); + $this->warn('Your API Token has been created. Be sure to copy this token now, as it will not be accessible again.'); + $this->info('API Token ID: '.$token->id); $this->info('API Token User: '.$user->present()->fullName.' ('.$user->username.')'); $this->info('API Token Name: '.$accessTokenName); $this->info('API Token: '.$user->createToken($accessTokenName)->accessToken);