Do not logout clientside if a network error occurs
This commit is contained in:
parent
1182d65bae
commit
ba609d4e37
|
|
@ -1,4 +1,4 @@
|
||||||
import axios, {AxiosResponse} from 'axios';
|
import axios, {AxiosError, AxiosResponse} from 'axios';
|
||||||
import * as config from './config';
|
import * as config from './config';
|
||||||
import {Base64} from 'js-base64';
|
import {Base64} from 'js-base64';
|
||||||
import {detect} from 'detect-browser';
|
import {detect} from 'detect-browser';
|
||||||
|
|
@ -84,8 +84,15 @@ export class CurrentUser {
|
||||||
this.loggedIn = true;
|
this.loggedIn = true;
|
||||||
return passThrough;
|
return passThrough;
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error: AxiosError) => {
|
||||||
this.logout();
|
if (
|
||||||
|
error &&
|
||||||
|
error.response &&
|
||||||
|
error.response.status >= 400 &&
|
||||||
|
error.response.status < 500
|
||||||
|
) {
|
||||||
|
this.logout();
|
||||||
|
}
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,8 @@ export class WebSocketStore {
|
||||||
.catch((error: AxiosError) => {
|
.catch((error: AxiosError) => {
|
||||||
if (error && error.response && error.response.status === 401) {
|
if (error && error.response && error.response.status === 401) {
|
||||||
this.snack('Could not authenticate with client token, logging out.');
|
this.snack('Could not authenticate with client token, logging out.');
|
||||||
|
} else {
|
||||||
|
this.snack('Lost network connection, please refresh the page.');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue