Skip to content

Commit

Permalink
Revert "[11.x] Add Provider Guard to ClientRepository for Personal Ac…
Browse files Browse the repository at this point in the history
…cess Clients (#1655)" (#1658)

This reverts commit a75f0a9.
  • Loading branch information
driesvints authored Apr 28, 2023
1 parent 487f183 commit 48a03ff
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 24 deletions.
5 changes: 2 additions & 3 deletions src/ClientRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,11 @@ public function create($userId, $name, $redirect, $provider = null, $personalAcc
* @param int|null $userId
* @param string $name
* @param string $redirect
* @param string|null $provider
* @return \Laravel\Passport\Client
*/
public function createPersonalAccessClient($userId, $name, $redirect, $provider = null)
public function createPersonalAccessClient($userId, $name, $redirect)
{
return tap($this->create($userId, $name, $redirect, $provider, true), function ($client) {
return tap($this->create($userId, $name, $redirect, null, true), function ($client) {
$accessClient = Passport::personalAccessClient();
$accessClient->client_id = $client->getKey();
$accessClient->save();
Expand Down
28 changes: 8 additions & 20 deletions src/Console/ClientCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,8 @@ protected function createPersonalClient(ClientRepository $clients)
config('app.name').' Personal Access Client'
);

$provider = $this->promptForProvider();

$client = $clients->createPersonalAccessClient(
null, $name, 'http://localhost', $provider
null, $name, 'http://localhost'
);

$this->info('Personal access client created successfully.');
Expand All @@ -87,7 +85,13 @@ protected function createPasswordClient(ClientRepository $clients)
config('app.name').' Password Grant Client'
);

$provider = $this->promptForProvider();
$providers = array_keys(config('auth.providers'));

$provider = $this->option('provider') ?: $this->choice(
'Which user provider should this client use to retrieve users?',
$providers,
in_array('users', $providers) ? 'users' : null
);

$client = $clients->createPasswordGrantClient(
null, $name, 'http://localhost', $provider
Expand Down Expand Up @@ -150,22 +154,6 @@ protected function createAuthCodeClient(ClientRepository $clients)
$this->outputClientDetails($client);
}

/**
* Ask the user what user provider should be used.
*
* @return string
*/
protected function promptForProvider()
{
$providers = array_keys(config('auth.providers'));

return $this->option('provider') ?: $this->choice(
'Which user provider should this client use to retrieve users?',
$providers,
in_array('users', $providers) ? 'users' : null
);
}

/**
* Output the client's ID and secret key.
*
Expand Down
2 changes: 1 addition & 1 deletion src/Console/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function handle()
$this->configureUuids();
}

$this->call('passport:client', ['--personal' => true, '--name' => config('app.name').' Personal Access Client', '--provider' => $provider]);
$this->call('passport:client', ['--personal' => true, '--name' => config('app.name').' Personal Access Client']);
$this->call('passport:client', ['--password' => true, '--name' => config('app.name').' Password Grant Client', '--provider' => $provider]);
}

Expand Down

0 comments on commit 48a03ff

Please sign in to comment.