From d6ddd9c1959ffef1e07b9377198263cf33babe5e Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Thu, 1 Feb 2018 12:13:33 +0100 Subject: [PATCH] Clearly remove auth data from storage --- client/coral-admin/src/actions/auth.js | 3 +++ client/coral-embed-stream/src/actions/auth.js | 3 +++ plugins/talk-plugin-auth/client/components/SignInContainer.js | 1 + 3 files changed, 7 insertions(+) diff --git a/client/coral-admin/src/actions/auth.js b/client/coral-admin/src/actions/auth.js index 332d756c0..6892080cd 100644 --- a/client/coral-admin/src/actions/auth.js +++ b/client/coral-admin/src/actions/auth.js @@ -33,6 +33,7 @@ export const handleLogin = (email, password, recaptchaResponse) => ( if (!user) { if (!bowser.safari && !bowser.ios && storage) { storage.removeItem('token'); + storage.removeItem('exp'); } return dispatch(checkLoginFailure('not logged in')); } @@ -128,6 +129,7 @@ export const checkLogin = () => (dispatch, _, { rest, client, storage }) => { if (!user) { if (!bowser.safari && !bowser.ios && storage) { storage.removeItem('token'); + storage.removeItem('exp'); } return dispatch(checkLoginFailure('not logged in')); } @@ -152,6 +154,7 @@ export const logout = () => (dispatch, _, { rest, client, storage }) => { return rest('/auth', { method: 'DELETE' }).then(() => { if (storage) { storage.removeItem('token'); + storage.removeItem('exp'); } // Reset the websocket. diff --git a/client/coral-embed-stream/src/actions/auth.js b/client/coral-embed-stream/src/actions/auth.js index e74265026..4406c744c 100644 --- a/client/coral-embed-stream/src/actions/auth.js +++ b/client/coral-embed-stream/src/actions/auth.js @@ -266,6 +266,7 @@ export const logout = () => async ( if (storage) { storage.removeItem('token'); + storage.removeItem('exp'); } // Reset the websocket. @@ -304,6 +305,7 @@ export const checkLogin = () => ( if (!result.user) { if (storage) { storage.removeItem('token'); + storage.removeItem('exp'); } throw ErrNotLoggedIn; } @@ -329,6 +331,7 @@ export const checkLogin = () => ( if (error.status && error.status === 401 && storage) { // Unauthorized. storage.removeItem('token'); + storage.removeItem('exp'); } const errorMessage = error.translation_key ? t(`error.${error.translation_key}`) diff --git a/plugins/talk-plugin-auth/client/components/SignInContainer.js b/plugins/talk-plugin-auth/client/components/SignInContainer.js index a4dec87e5..4dc072feb 100644 --- a/plugins/talk-plugin-auth/client/components/SignInContainer.js +++ b/plugins/talk-plugin-auth/client/components/SignInContainer.js @@ -60,6 +60,7 @@ class SignInContainer extends React.Component { if (e.key === 'auth') { const { err, data } = JSON.parse(e.newValue); authCallback(err, data); + localStorage.removeItem('auth'); } };