From 5787811a5b9392f98d94ba6d3a72dba567284bbb Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 19 May 2019 08:37:49 +0200 Subject: [PATCH] BUG FIXED: Master App was deleting ALL localstorage when logging out including information of others including Canvas APP --- client/src/auth/index.js | 4 +++- client/src/graphql/apollo.js | 4 +++- client/src/views/layout/header/index.js | 6 ++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/client/src/auth/index.js b/client/src/auth/index.js index 8ef99e1ff..e616758b2 100644 --- a/client/src/auth/index.js +++ b/client/src/auth/index.js @@ -213,7 +213,9 @@ class Auth { logout () { // Clear access token and ID token from local storage - window.localStorage.clear() + window.localStorage.removeItem('access_token') + window.localStorage.removeItem('user') + window.localStorage.removeItem('name') deleteCookie('ajs_anonymous_id') deleteCookie('ajs_user_id') deleteCookie('current_tenant') diff --git a/client/src/graphql/apollo.js b/client/src/graphql/apollo.js index a07faac41..283cfc868 100644 --- a/client/src/graphql/apollo.js +++ b/client/src/graphql/apollo.js @@ -15,7 +15,9 @@ const authRetryLink = onError( // User access token has expired // console.log('authLink: ', graphQLErrors) // check for error message to intercept and resend with Auth0 access token if (graphQLErrors[0].message === 'Context creation failed: jwt expired') { - window.localStorage.clear() + window.localStorage.removeItem('access_token') + window.localStorage.removeItem('user') + window.localStorage.removeItem('name') location.reload() } else if (graphQLErrors[0].message === 'Not logged in') { // We assume we have auth0 access token needed to run the async request diff --git a/client/src/views/layout/header/index.js b/client/src/views/layout/header/index.js index 793531d83..224129f4a 100644 --- a/client/src/views/layout/header/index.js +++ b/client/src/views/layout/header/index.js @@ -76,7 +76,9 @@ class Header extends Component { let { onTop, mobileOpen, openedMenu } = this.state if (window.localStorage.getItem('access_token')) { if (jwtDecode(window.localStorage.getItem('access_token')).exp < new Date().getTime() / 1000) { - window.localStorage.clear() + window.localStorage.removeItem('access_token') + window.localStorage.removeItem('user') + window.localStorage.removeItem('name') window.location.reload() } } @@ -86,7 +88,7 @@ class Header extends Component { if (authenticated && !(this.state.user !== undefined && this.state.user !== null)) { return } - let cssChildren = submenus.length === 0 ? null : 'hasChildren'; + let cssChildren = submenus.length === 0 ? null : 'hasChildren' return (
  • this.toggleMenuOpen(index, bigScreen)}