Files
firefly-iii/resources/assets/js/components/passport/AuthorizedClients.vue

136 lines
3.9 KiB
Vue
Raw Normal View History

2019-05-29 21:56:39 +02:00
<!--
- AuthorizedClients.vue
- Copyright (c) 2019 thegrumpydictator@gmail.com
-
- This file is part of Firefly III.
-
- Firefly III is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Firefly III is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
-->
2019-01-01 15:44:55 +01:00
<!-- TODO REMOVE ME -->
<style scoped>
.action-link {
cursor: pointer;
}
.m-b-none {
margin-bottom: 0;
}
</style>
<template>
<div>
<div v-if="tokens.length > 0">
2018-02-04 15:58:03 +01:00
<div class="box box-primary">
<div class="box-header with-border">
<h3 class="box-title">
Authorized Applications
</h3>
</div>
<div class="box-body">
<!-- Authorized Tokens -->
<table class="table table-borderless m-b-none">
<thead>
2018-02-04 15:58:03 +01:00
<tr>
<th>Name</th>
<th>Scopes</th>
<th></th>
</tr>
</thead>
<tbody>
2018-02-04 15:58:03 +01:00
<tr v-for="token in tokens">
<!-- Client Name -->
<td style="vertical-align: middle;">
{{ token.client.name }}
</td>
2018-02-04 15:58:03 +01:00
<!-- Scopes -->
<td style="vertical-align: middle;">
<span v-if="token.scopes.length > 0">
{{ token.scopes.join(', ') }}
</span>
2018-02-04 15:58:03 +01:00
</td>
2018-02-04 15:58:03 +01:00
<!-- Revoke Button -->
<td style="vertical-align: middle;">
<a class="action-link btn btn-danger btn-xs" @click="revoke(token)">
Revoke
</a>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
/*
* The component's data.
*/
data() {
return {
tokens: []
};
},
/**
* Prepare the component (Vue 1.x).
*/
ready() {
this.prepareComponent();
},
/**
* Prepare the component (Vue 2.x).
*/
mounted() {
this.prepareComponent();
},
methods: {
/**
* Prepare the component (Vue 2.x).
*/
prepareComponent() {
this.getTokens();
},
/**
* Get all of the authorized tokens for the user.
*/
getTokens() {
axios.get('./oauth/tokens')
2018-02-04 15:58:03 +01:00
.then(response => {
this.tokens = response.data;
});
},
/**
* Revoke the given token.
*/
revoke(token) {
axios.delete('./oauth/tokens/' + token.id)
2018-02-04 15:58:03 +01:00
.then(response => {
this.getTokens();
});
}
}
}
</script>