Add logout button
This commit is contained in:
parent
d9b3012153
commit
18d054edf0
@ -3,9 +3,12 @@
|
|||||||
|
|
||||||
<container>
|
<container>
|
||||||
<p>
|
<p>
|
||||||
<span v-if="!!tokenId">Authenticated with token ID {{ tokenId }}</span><br/>
|
<span v-if="!!tokenId">Authenticated with token ID {{ tokenId }}</span>
|
||||||
|
<br/>
|
||||||
Authentication status: {{ status ? 'Valid' : 'Invalid' }}
|
Authentication status: {{ status ? 'Valid' : 'Invalid' }}
|
||||||
<button @click="checkValidity">Refresh</button>
|
<button @click="checkValidity">Refresh</button>
|
||||||
|
<br/>
|
||||||
|
<button @click="logout">Logout</button>
|
||||||
</p>
|
</p>
|
||||||
</container>
|
</container>
|
||||||
</template>
|
</template>
|
||||||
@ -57,7 +60,17 @@ export default {
|
|||||||
return tokenData.token;
|
return tokenData.token;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
logout() {
|
||||||
|
axios.defaults.headers.common.Authorization = null;
|
||||||
|
|
||||||
|
if (!!window.localStorage.getItem('authentication-token')) {
|
||||||
|
window.localStorage.removeItem('authentication-token');
|
||||||
|
}
|
||||||
|
|
||||||
|
this.status = false;
|
||||||
|
this.tokenId = null;
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user