Add logout button

This commit is contained in:
Daniel_I_Am 2021-09-02 13:02:27 +02:00
parent d9b3012153
commit 18d054edf0

View File

@ -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>