Skip to content
This repository has been archived by the owner on Oct 6, 2019. It is now read-only.

Commit

Permalink
Added revoke-self button. Closed #232
Browse files Browse the repository at this point in the history
  • Loading branch information
Caiyeon committed Feb 14, 2018
1 parent 5230a21 commit dd2576b
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions frontend/client/views/login/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,16 @@
</tbody>
</table>
<p v-if="session !== null" class="control">
<button class="button is-warning" @click="logout()">
Logout
</button>
<button v-if="renewable" class="button is-primary"
@click="renewLogin()">
Renew
</button>
<button class="button is-warning" @click="logout(false)">
Forget Token
</button>
<button class="button is-warning" @click="logout(true)">
Revoke Token
</button>
</p>
</div>
</article>
Expand Down Expand Up @@ -430,7 +433,7 @@ export default {
})
.catch((error) => {
// to avoid ambiguity, current session should be purged when new login fails
this.logout()
this.logout(false)
this.$onError(error)
if (this.bCustomPath && error.response.status === 400 &&
error.response.data.error === 'Vault: missing client token') {
Expand All @@ -444,7 +447,24 @@ export default {
})
},
logout: function () {
logout: function (revoke) {
// if user wants to revoke token
if (revoke) {
this.$http.post('/v1/token/revoke-self', {}, {
headers: {'X-Vault-Token': this.session ? this.session.token : ''}
})
.then((response) => {
// notify user, and clear inputs
this.$notify({
title: 'Token revoked!',
message: '',
type: 'success'
})
})
.catch((error) => {
this.$onError(error)
})
}
// purge session from localstorage
window.localStorage.removeItem('session')
// mutate vuex state
Expand Down

0 comments on commit dd2576b

Please sign in to comment.