Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[9.x] Implement secret modal #1258

Merged
merged 4 commits into from
May 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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