-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
248fac7
commit f426cba
Showing
2 changed files
with
125 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
<?php | ||
|
||
namespace DesignMyNight\Mongodb\Console; | ||
|
||
use DesignMyNight\Mongodb\Passport\Client; | ||
use Laravel\Passport\ClientRepository; | ||
use Laravel\Passport\Console\ClientCommand as PassportClientCommand; | ||
|
||
class ClientCommand extends PassportClientCommand | ||
{ | ||
/** | ||
* Create a new personal access client. | ||
* | ||
* @param \Laravel\Passport\ClientRepository $clients | ||
* @return void | ||
*/ | ||
protected function createPersonalClient(ClientRepository $clients) | ||
{ | ||
$name = $this->option('name') ?: $this->ask( | ||
'What should we name the personal access client?', | ||
config('app.name').' Personal Access Client' | ||
); | ||
|
||
$client = $clients->createPersonalAccessClient( | ||
null, $name, 'http://localhost' | ||
); | ||
|
||
$this->info('Personal access client created successfully.'); | ||
|
||
$this->patchedOutputClientDetails($client); | ||
} | ||
|
||
/** | ||
* Create a new password grant client. | ||
* | ||
* @param \Laravel\Passport\ClientRepository $clients | ||
* @return void | ||
*/ | ||
protected function createPasswordClient(ClientRepository $clients) | ||
{ | ||
$name = $this->option('name') ?: $this->ask( | ||
'What should we name the password grant client?', | ||
config('app.name').' Password Grant Client' | ||
); | ||
|
||
$client = $clients->createPasswordGrantClient( | ||
null, $name, 'http://localhost' | ||
); | ||
|
||
$this->info('Password grant client created successfully.'); | ||
|
||
$this->patchedOutputClientDetails($client); | ||
} | ||
|
||
/** | ||
* Create a client credentials grant client. | ||
* | ||
* @param \Laravel\Passport\ClientRepository $clients | ||
* @return void | ||
*/ | ||
protected function createClientCredentialsClient(ClientRepository $clients) | ||
{ | ||
$name = $this->option('name') ?: $this->ask( | ||
'What should we name the client?', | ||
config('app.name').' ClientCredentials Grant Client' | ||
); | ||
|
||
$client = $clients->create( | ||
null, $name, '' | ||
); | ||
|
||
$this->info('New client created successfully.'); | ||
|
||
$this->patchedOutputClientDetails($client); | ||
} | ||
|
||
/** | ||
* Create a authorization code client. | ||
* | ||
* @param \Laravel\Passport\ClientRepository $clients | ||
* @return void | ||
*/ | ||
protected function createAuthCodeClient(ClientRepository $clients) | ||
{ | ||
$userId = $this->option('user_id') ?: $this->ask( | ||
'Which user ID should the client be assigned to?' | ||
); | ||
|
||
$name = $this->option('name') ?: $this->ask( | ||
'What should we name the client?' | ||
); | ||
|
||
$redirect = $this->option('redirect_uri') ?: $this->ask( | ||
'Where should we redirect the request after authorization?', | ||
url('/auth/callback') | ||
); | ||
|
||
$client = $clients->create( | ||
$userId, $name, $redirect, false, false, ! $this->option('public') | ||
); | ||
|
||
$this->info('New client created successfully.'); | ||
|
||
$this->patchedOutputClientDetails($client); | ||
} | ||
|
||
/** | ||
* Output the client's ID and secret key. | ||
* | ||
* @param \Laravel\Passport\Client $client | ||
* @return void | ||
*/ | ||
protected function patchedOutputClientDetails(Client $client) | ||
{ | ||
$this->line('<comment>Client ID:</comment> '.$client->id); | ||
$this->line('<comment>Client secret:</comment> '.$client->secret); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters