Skip to content

Commit ab797a3

Browse files
[9.x] Implement secret modal (#1258)
* Implement secret modal * Add upgrade note on vue assets * Revert change * Update UPGRADE.md Co-authored-by: Taylor Otwell <taylor@laravel.com>
1 parent 2c24ae4 commit ab797a3

File tree

3 files changed

+52
-6
lines changed

3 files changed

+52
-6
lines changed

UPGRADE.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Upgrade Guide
22

3+
## General Notes
4+
5+
After updating Passport, you should always re-publish and re-compile the Vue "quickstart" assets if you're using them:
6+
7+
php artisan vendor:publish --tag=passport-views --force
8+
39
## Upgrading To 9.0 From 8.0
410

511
### Support For Multiple Guards

resources/js/components/Clients.vue

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,35 @@
224224
</div>
225225
</div>
226226
</div>
227+
228+
<!-- Client Secret Modal -->
229+
<div class="modal fade" id="modal-client-secret" tabindex="-1" role="dialog">
230+
<div class="modal-dialog">
231+
<div class="modal-content">
232+
<div class="modal-header">
233+
<h4 class="modal-title">
234+
Client Secret
235+
</h4>
236+
237+
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
238+
</div>
239+
240+
<div class="modal-body">
241+
<p>
242+
Here is your new client secret. This is the only time it will be shown so don't lose it!
243+
You may now use this secret to make API requests.
244+
</p>
245+
246+
<input type="text" class="form-control" v-model="clientSecret">
247+
</div>
248+
249+
<!-- Modal Actions -->
250+
<div class="modal-footer">
251+
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
252+
</div>
253+
</div>
254+
</div>
255+
</div>
227256
</div>
228257
</template>
229258

@@ -236,6 +265,8 @@
236265
return {
237266
clients: [],
238267
268+
clientSecret: null,
269+
239270
createForm: {
240271
errors: [],
241272
name: '',
@@ -341,17 +372,17 @@
341372
342373
axios[method](uri, form)
343374
.then(response => {
344-
if (method === 'post') {
345-
this.clients.push(response.data);
346-
} else {
347-
this.getClients();
348-
}
375+
this.getClients();
349376
350377
form.name = '';
351378
form.redirect = '';
352379
form.errors = [];
353380
354381
$(modal).modal('hide');
382+
383+
if (response.data.plainSecret) {
384+
this.showClientSecret(response.data.plainSecret);
385+
}
355386
})
356387
.catch(error => {
357388
if (typeof error.response.data === 'object') {
@@ -362,6 +393,15 @@
362393
});
363394
},
364395
396+
/**
397+
* Show the given client secret to the user.
398+
*/
399+
showClientSecret(clientSecret) {
400+
this.clientSecret = clientSecret;
401+
402+
$('#modal-client-secret').modal('show');
403+
},
404+
365405
/**
366406
* Destroy the given client.
367407
*/

src/Http/Controllers/ClientController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function store(Request $request)
8989
);
9090

9191
if (Passport::$hashesClientSecrets) {
92-
return ['secret' => $client->plainSecret] + $client->toArray();
92+
return ['plainSecret' => $client->plainSecret] + $client->toArray();
9393
}
9494

9595
return $client->makeVisible('secret');

0 commit comments

Comments
 (0)