From 59b18b37d3bd601a2aac717dc364bc7dbf07c13c Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Fri, 28 Apr 2023 08:20:15 +0200 Subject: [PATCH] Revert "[11.x] Add Provider Guard to ClientRepository for Personal Access Clients (#1655)" This reverts commit a75f0a92136a6cf91e5c6755374f77bf4b30c411. --- src/ClientRepository.php | 5 ++--- src/Console/ClientCommand.php | 28 ++++++++-------------------- src/Console/InstallCommand.php | 2 +- 3 files changed, 11 insertions(+), 24 deletions(-) diff --git a/src/ClientRepository.php b/src/ClientRepository.php index 5fc2fab0a..2809b3ae1 100644 --- a/src/ClientRepository.php +++ b/src/ClientRepository.php @@ -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(); diff --git a/src/Console/ClientCommand.php b/src/Console/ClientCommand.php index 2a9f47cc5..c46f63bc6 100644 --- a/src/Console/ClientCommand.php +++ b/src/Console/ClientCommand.php @@ -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.'); @@ -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 @@ -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. * diff --git a/src/Console/InstallCommand.php b/src/Console/InstallCommand.php index a5311c47f..f5ed11023 100644 --- a/src/Console/InstallCommand.php +++ b/src/Console/InstallCommand.php @@ -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]); }