From 9c3c2b836facd82c6ad8c26c3c4cca46fe0d2e82 Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Fri, 8 May 2020 12:22:30 +0200 Subject: [PATCH 1/4] Implement secret modal --- resources/js/components/Clients.vue | 50 ++++++++++++++++++++--- src/Http/Controllers/ClientController.php | 10 ++++- 2 files changed, 53 insertions(+), 7 deletions(-) diff --git a/resources/js/components/Clients.vue b/resources/js/components/Clients.vue index 7a50deea8..a89003fff 100644 --- a/resources/js/components/Clients.vue +++ b/resources/js/components/Clients.vue @@ -224,6 +224,35 @@ + + + @@ -236,6 +265,8 @@ return { clients: [], + clientSecret: null, + createForm: { errors: [], name: '', @@ -341,17 +372,17 @@ axios[method](uri, form) .then(response => { - if (method === 'post') { - this.clients.push(response.data); - } else { - this.getClients(); - } + this.getClients(); form.name = ''; form.redirect = ''; form.errors = []; $(modal).modal('hide'); + + if (response.data.plainSecret) { + this.showClientSecret(response.data.plainSecret); + } }) .catch(error => { if (typeof error.response.data === 'object') { @@ -362,6 +393,15 @@ }); }, + /** + * Show the given client secret to the user. + */ + showClientSecret(clientSecret) { + this.clientSecret = clientSecret; + + $('#modal-client-secret').modal('show'); + }, + /** * Destroy the given client. */ diff --git a/src/Http/Controllers/ClientController.php b/src/Http/Controllers/ClientController.php index 219973441..201b0d807 100644 --- a/src/Http/Controllers/ClientController.php +++ b/src/Http/Controllers/ClientController.php @@ -89,7 +89,7 @@ public function store(Request $request) ); if (Passport::$hashesClientSecrets) { - return ['secret' => $client->plainSecret] + $client->toArray(); + return ['plainSecret' => $client->plainSecret] + $client->toArray(); } return $client->makeVisible('secret'); @@ -115,9 +115,15 @@ public function update(Request $request, $clientId) 'redirect' => ['required', $this->redirectRule], ])->validate(); - return $this->clients->update( + $client = $this->clients->update( $client, $request->name, $request->redirect ); + + if (Passport::$hashesClientSecrets) { + return $client; + } + + return $client->makeVisible('secret'); } /** From dcb8473b89d296b37e67bc32c6d5fecc3cb50f5a Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Fri, 8 May 2020 12:25:59 +0200 Subject: [PATCH 2/4] Add upgrade note on vue assets --- UPGRADE.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/UPGRADE.md b/UPGRADE.md index 63e955571..75d14a089 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,11 @@ # Upgrade Guide +## General Notes + +In general, every time you update Passport, it's best that you re-publish and re-compile the Vue assets if you're using them: + + php artisan vendor:publish --tag=passport-views --force + ## Upgrading To 9.0 From 8.0 ### Support For Multiple Guards From d0529979093dbb858173175e0caa5aba557eb1a9 Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Fri, 8 May 2020 12:33:53 +0200 Subject: [PATCH 3/4] Revert change --- src/Http/Controllers/ClientController.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/Http/Controllers/ClientController.php b/src/Http/Controllers/ClientController.php index 201b0d807..7ce9fde04 100644 --- a/src/Http/Controllers/ClientController.php +++ b/src/Http/Controllers/ClientController.php @@ -115,15 +115,9 @@ public function update(Request $request, $clientId) 'redirect' => ['required', $this->redirectRule], ])->validate(); - $client = $this->clients->update( + return $this->clients->update( $client, $request->name, $request->redirect ); - - if (Passport::$hashesClientSecrets) { - return $client; - } - - return $client->makeVisible('secret'); } /** From 9bcca4a2b499344c73f6a3b694c7f3e4a009713c Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Fri, 8 May 2020 08:50:55 -0500 Subject: [PATCH 4/4] Update UPGRADE.md --- UPGRADE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UPGRADE.md b/UPGRADE.md index 75d14a089..a3d49766f 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -2,7 +2,7 @@ ## General Notes -In general, every time you update Passport, it's best that you re-publish and re-compile the Vue assets if you're using them: +After updating Passport, you should always re-publish and re-compile the Vue "quickstart" assets if you're using them: php artisan vendor:publish --tag=passport-views --force