diff --git a/app/components/Auth.js b/app/components/Auth.js index b681398f..90c9fd20 100644 --- a/app/components/Auth.js +++ b/app/components/Auth.js @@ -51,7 +51,6 @@ const Auth = ({ children }: Props) => { } stores.auth.logout(); - window.location.href = BASE_URL; return null; }; diff --git a/app/menus/AccountMenu.js b/app/menus/AccountMenu.js index 4396f5d7..c317db1b 100644 --- a/app/menus/AccountMenu.js +++ b/app/menus/AccountMenu.js @@ -30,7 +30,6 @@ class AccountMenu extends Component { handleLogout = () => { this.props.auth.logout(); - window.location.href = BASE_URL; }; handleFeedback = () => { diff --git a/app/scenes/Home/Home.js b/app/scenes/Home/Home.js index 59d703d7..3c2f46c1 100644 --- a/app/scenes/Home/Home.js +++ b/app/scenes/Home/Home.js @@ -11,8 +11,6 @@ type Props = { const Home = observer(({ auth }: Props) => { if (auth.authenticated) return ; auth.logout(); - - window.location.href = BASE_URL; return null; }); diff --git a/app/stores/AuthStore.js b/app/stores/AuthStore.js index e5b41bee..05fa14a0 100644 --- a/app/stores/AuthStore.js +++ b/app/stores/AuthStore.js @@ -42,17 +42,20 @@ class AuthStore { this.user = res.data.user; this.team = res.data.team; }); - } catch (e) { + } catch (err) { // Failure to update user info is a non-fatal error. + console.error(err); } }; @action - logout = () => { + logout = async () => { this.user = null; this.token = null; - localForage.clear(); + Cookie.remove('loggedIn', { path: '/' }); + await localForage.clear(); + window.location.href = BASE_URL; }; @action diff --git a/app/utils/ApiClient.js b/app/utils/ApiClient.js index 08789da2..88689709 100644 --- a/app/utils/ApiClient.js +++ b/app/utils/ApiClient.js @@ -67,7 +67,6 @@ class ApiClient { // Handle 401, log out user if (response.status === 401) { stores.auth.logout(); - window.location = '/'; return; }