From e9800b51f1faf5f442f05ed0b2310553d98c067c Mon Sep 17 00:00:00 2001 From: Yoshie Muranaka Date: Thu, 7 May 2020 11:11:30 -0700 Subject: 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 Change-Id: I9f2b7025ff1de21889267b8f56efd08930eb63d3 --- src/router/index.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/router/index.js b/src/router/index.js index c3d44390..33743fe0 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -98,6 +98,9 @@ const router = new VueRouter({ }); 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(); -- cgit v1.2.3