diff --git a/app/Console/Commands/GeneratePersonalAccessToken.php b/app/Console/Commands/GeneratePersonalAccessToken.php new file mode 100644 index 0000000000..ae62064215 --- /dev/null +++ b/app/Console/Commands/GeneratePersonalAccessToken.php @@ -0,0 +1,85 @@ +validation = $validation; + $this->tokenRepository = $tokenRepository; + parent::__construct(); + } + + /** + * Execute the console command. + * + * @return int + */ + public function handle() + { + + if ($this->option('name')=='') { + $accessTokenName = 'CLI Auth Token'; + } + + if ($this->argument('user')=='') { + return false; + } + + if ($user = User::find($this->argument('user'))) { + + if ($this->option('key-only')=='true') { + $this->info($user->createToken($accessTokenName)->accessToken); + } else { + $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 Name: '.$accessTokenName); + $this->info('API Token: '.$user->createToken($accessTokenName)->accessToken); + } + } else { + return $this->error('ERROR: Invalid user. API key was not created.'); + } + + + + + } +}