Clear application state on logout
Remove the authError state property from the logout mutation
since the the authError would not be in the true state after
a successful login.
Signed-off-by: Derick Montague <derick.montague@ibm.com>
Change-Id: Ibfe8b07c4e9e37dfab4435596c12e9a36556a714
diff --git a/src/components/AppHeader/AppHeader.vue b/src/components/AppHeader/AppHeader.vue
index b2d29c9..880c428 100644
--- a/src/components/AppHeader/AppHeader.vue
+++ b/src/components/AppHeader/AppHeader.vue
@@ -66,9 +66,7 @@
this.$store.dispatch('global/getHostStatus');
},
logout() {
- this.$store.dispatch('authentication/logout').then(() => {
- this.$router.push('/login');
- });
+ this.$store.dispatch('authentication/logout');
}
}
};
diff --git a/src/store/modules/Authentication/AuthenticanStore.js b/src/store/modules/Authentication/AuthenticanStore.js
index 8d8898e..975f258 100644
--- a/src/store/modules/Authentication/AuthenticanStore.js
+++ b/src/store/modules/Authentication/AuthenticanStore.js
@@ -1,5 +1,6 @@
import api from '../../api';
import Cookies from 'js-cookie';
+import router from '../../../router';
const AuthenticationStore = {
namespaced: true,
@@ -19,8 +20,7 @@
authError(state) {
state.authError = true;
},
- logout(state) {
- state.authError = false;
+ logout() {
Cookies.remove('XSRF-TOKEN');
}
},
@@ -38,6 +38,7 @@
api
.post('/logout', { data: [] })
.then(() => commit('logout'))
+ .then(() => router.go('/login'))
.catch(error => console.log(error));
}
}