From ba609d4e37997cb577a0b4317f5a8dccfde54e1a Mon Sep 17 00:00:00 2001 From: Jannis Mattheis Date: Fri, 22 Mar 2019 17:32:09 +0100 Subject: [PATCH] Do not logout clientside if a network error occurs --- ui/src/CurrentUser.ts | 13 ++++++++++--- ui/src/message/WebSocketStore.ts | 2 ++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/ui/src/CurrentUser.ts b/ui/src/CurrentUser.ts index fb08056..82b901d 100644 --- a/ui/src/CurrentUser.ts +++ b/ui/src/CurrentUser.ts @@ -1,4 +1,4 @@ -import axios, {AxiosResponse} from 'axios'; +import axios, {AxiosError, AxiosResponse} from 'axios'; import * as config from './config'; import {Base64} from 'js-base64'; import {detect} from 'detect-browser'; @@ -84,8 +84,15 @@ export class CurrentUser { this.loggedIn = true; return passThrough; }) - .catch((error) => { - this.logout(); + .catch((error: AxiosError) => { + if ( + error && + error.response && + error.response.status >= 400 && + error.response.status < 500 + ) { + this.logout(); + } return Promise.reject(error); }); }; diff --git a/ui/src/message/WebSocketStore.ts b/ui/src/message/WebSocketStore.ts index f7747f2..215e219 100644 --- a/ui/src/message/WebSocketStore.ts +++ b/ui/src/message/WebSocketStore.ts @@ -42,6 +42,8 @@ export class WebSocketStore { .catch((error: AxiosError) => { if (error && error.response && error.response.status === 401) { this.snack('Could not authenticate with client token, logging out.'); + } else { + this.snack('Lost network connection, please refresh the page.'); } }); };