Do not logout clientside if a network error occurs

This commit is contained in:
Jannis Mattheis 2019-03-22 17:32:09 +01:00
parent 1182d65bae
commit ba609d4e37
2 changed files with 12 additions and 3 deletions

View File

@ -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) => {
.catch((error: AxiosError) => {
if (
error &&
error.response &&
error.response.status >= 400 &&
error.response.status < 500
) {
this.logout();
}
return Promise.reject(error);
});
};

View File

@ -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.');
}
});
};