From 18d054edf0818a3c9b7c9c8236817aad743adb83 Mon Sep 17 00:00:00 2001 From: Daniel-I-Am Date: Thu, 2 Sep 2021 13:02:27 +0200 Subject: [PATCH] Add logout button --- resources/js/views/Login.vue | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/resources/js/views/Login.vue b/resources/js/views/Login.vue index 1f469f9..4977ccd 100644 --- a/resources/js/views/Login.vue +++ b/resources/js/views/Login.vue @@ -3,9 +3,12 @@

- Authenticated with token ID {{ tokenId }}
+ Authenticated with token ID {{ tokenId }} +
Authentication status: {{ status ? 'Valid' : 'Invalid' }} +
+

@@ -57,7 +60,17 @@ export default { 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; + }, } }