Clear XSRF token when navigating to Login
This will fix the WebSocket authentication error if redirected to
the Login page when a session is expired. The WebSocketPlugin checks
to see if the user is logged in before attempting to make a connection.
The AuthenticationStore determines if a user is logged in
based on whether or not the XSRF-TOKEN cookie exists. Currently the
app only removes this token if the user explicitly logs out from
the application header.
Signed-off-by: Yoshie Muranaka <yoshiemuranaka@gmail.com>
Change-Id: I9f2b7025ff1de21889267b8f56efd08930eb63d3
diff --git a/src/router/index.js b/src/router/index.js
index c3d4439..33743fe 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -98,6 +98,9 @@
});
router.beforeEach((to, from, next) => {
+ // Commit logout to remove XSRF-TOKEN cookie when
+ // redirected to login page (eg 401 response)
+ if (to.name === 'login') store.commit('authentication/logout');
if (to.matched.some(record => record.meta.requiresAuth)) {
if (store.getters['authentication/isLoggedIn']) {
next();