From 25b2b2a024aebb7b61fa9739da45fd8e9b95e971 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sat, 11 Nov 2017 14:42:29 -0800 Subject: [PATCH] Fixes: Infinite logout loop --- app/scenes/Home/Home.js | 6 ++++-- app/stores/AuthStore.js | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/scenes/Home/Home.js b/app/scenes/Home/Home.js index f3b7ba098..59d703d74 100644 --- a/app/scenes/Home/Home.js +++ b/app/scenes/Home/Home.js @@ -8,8 +8,10 @@ type Props = { auth: AuthStore, }; -const Home = observer((props: Props) => { - if (props.auth.authenticated) return ; +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 87e09ce03..5cb7bf948 100644 --- a/app/stores/AuthStore.js +++ b/app/stores/AuthStore.js @@ -1,5 +1,5 @@ // @flow -import { observable, action, computed, autorunAsync } from 'mobx'; +import { observable, action, computed, autorun } from 'mobx'; import invariant from 'invariant'; import Cookie from 'js-cookie'; import { client } from 'utils/ApiClient'; @@ -87,7 +87,7 @@ class AuthStore { this.token = data.token; this.oauthState = data.oauthState; - autorunAsync(() => { + autorun(() => { localStorage.setItem(AUTH_STORE, this.asJson); }); }