Skip to content

Commit

Permalink
[9.x] Implement secret modal (#1258)
Browse files Browse the repository at this point in the history
* Implement secret modal

* Add upgrade note on vue assets

* Revert change

* Update UPGRADE.md

Co-authored-by: Taylor Otwell <taylor@laravel.com>
  • Loading branch information
driesvints and taylorotwell authored May 8, 2020
1 parent 2c24ae4 commit ab797a3
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 6 deletions.
6 changes: 6 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Upgrade Guide

## General Notes

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

## Upgrading To 9.0 From 8.0

### Support For Multiple Guards
Expand Down
50 changes: 45 additions & 5 deletions resources/js/components/Clients.vue
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,35 @@
</div>
</div>
</div>

<!-- Client Secret Modal -->
<div class="modal fade" id="modal-client-secret" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">
Client Secret
</h4>

<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
</div>

<div class="modal-body">
<p>
Here is your new client secret. This is the only time it will be shown so don't lose it!
You may now use this secret to make API requests.
</p>

<input type="text" class="form-control" v-model="clientSecret">
</div>

<!-- Modal Actions -->
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
</template>

Expand All @@ -236,6 +265,8 @@
return {
clients: [],
clientSecret: null,
createForm: {
errors: [],
name: '',
Expand Down Expand Up @@ -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') {
Expand All @@ -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.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Controllers/ClientController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit ab797a3

Please sign in to comment.