summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerick Montague <derick.montague@ibm.com>2020-02-13 00:55:42 +0300
committerDerick Montague <derick.montague@ibm.com>2020-02-14 17:55:23 +0300
commitc031b6988d6381ae1d2ecefd04e8c2af47f0ff4a (patch)
tree6baf3d27353766f9c5bc5fc3ec943c6a199864de
parent537c6cb6b293665826efc5b1ef9f9c9c2e6a0d39 (diff)
downloadwebui-vue-c031b6988d6381ae1d2ecefd04e8c2af47f0ff4a.tar.xz
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
-rw-r--r--src/components/AppHeader/AppHeader.vue4
-rw-r--r--src/store/modules/Authentication/AuthenticanStore.js5
2 files changed, 4 insertions, 5 deletions
diff --git a/src/components/AppHeader/AppHeader.vue b/src/components/AppHeader/AppHeader.vue
index b2d29c95..880c428f 100644
--- a/src/components/AppHeader/AppHeader.vue
+++ b/src/components/AppHeader/AppHeader.vue
@@ -66,9 +66,7 @@ export default {
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 8d8898ef..975f258b 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 @@ const AuthenticationStore = {
authError(state) {
state.authError = true;
},
- logout(state) {
- state.authError = false;
+ logout() {
Cookies.remove('XSRF-TOKEN');
}
},
@@ -38,6 +38,7 @@ const AuthenticationStore = {
api
.post('/logout', { data: [] })
.then(() => commit('logout'))
+ .then(() => router.go('/login'))
.catch(error => console.log(error));
}
}