From 333f8624f1cc1c21e100819d0224c957c4285112 Mon Sep 17 00:00:00 2001 From: Dominik Guzei Date: Thu, 23 May 2019 11:31:34 +0200 Subject: logout user when access token is invalid --- src/stores/GlobalErrorStore.js | 7 +++++-- src/stores/UserStore.js | 3 +-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'src/stores') diff --git a/src/stores/GlobalErrorStore.js b/src/stores/GlobalErrorStore.js index 90bf751c3..7a85c2daa 100644 --- a/src/stores/GlobalErrorStore.js +++ b/src/stores/GlobalErrorStore.js @@ -18,8 +18,11 @@ export default class GlobalErrorStore extends Store { this.error = request.error; if (request.error.json) { - this.response = await request.error.json(); - + try { + this.response = await request.error.json(); + } catch (error) { + this.response = {}; + } if (this.error.status === 401) { this.actions.user.logout({ serverLogout: true }); } diff --git a/src/stores/UserStore.js b/src/stores/UserStore.js index 31555dd5c..b5423af3b 100644 --- a/src/stores/UserStore.js +++ b/src/stores/UserStore.js @@ -329,8 +329,7 @@ export default class UserStore extends Store { authToken, }); } catch (err) { - console.error('AccessToken Invalid'); - + this._logout(); return false; } } -- cgit v1.2.3-70-g09d2