mirror of
https://github.com/optim-enterprises-bv/OptimCloud-gw-ui.git
synced 2025-10-29 17:32:20 +00:00
Merge pull request #103 from stephb9959/main
[WIFI-10583] Reacting to more cases where a token might be expired/invalid
This commit is contained in:
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "ucentral-client",
|
||||
"version": "2.7.0(2)",
|
||||
"version": "2.7.0(3)",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "ucentral-client",
|
||||
"version": "2.7.0(2)",
|
||||
"version": "2.7.0(3)",
|
||||
"dependencies": {
|
||||
"@coreui/coreui": "^3.4.0",
|
||||
"@coreui/icons": "^2.0.1",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ucentral-client",
|
||||
"version": "2.7.0(2)",
|
||||
"version": "2.7.0(3)",
|
||||
"dependencies": {
|
||||
"@coreui/coreui": "^3.4.0",
|
||||
"@coreui/icons": "^2.0.1",
|
||||
|
||||
4
src/constants.js
Normal file
4
src/constants.js
Normal file
@@ -0,0 +1,4 @@
|
||||
export const AUTH_EXPIRED_TOKEN_CODE = 9;
|
||||
export const AUTH_INVALID_TOKEN_CODE = 8;
|
||||
|
||||
export const LOGOUT_ON_SEC_ERROR_CODES = [AUTH_EXPIRED_TOKEN_CODE, AUTH_INVALID_TOKEN_CODE];
|
||||
@@ -13,7 +13,7 @@ const Routes = () => {
|
||||
path="/"
|
||||
name="Devices"
|
||||
render={(props) =>
|
||||
currentToken !== '' && Object.keys(endpoints).length !== 0 ? (
|
||||
currentToken !== '' && endpoints && Object.keys(endpoints).length !== 0 ? (
|
||||
<TheLayout {...props} />
|
||||
) : (
|
||||
<ToastProvider>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import * as axios from 'axios';
|
||||
import axiosRetry from 'axios-retry';
|
||||
import { LOGOUT_ON_SEC_ERROR_CODES } from 'constants';
|
||||
|
||||
const axiosInstance = axios.create();
|
||||
|
||||
@@ -27,7 +28,7 @@ axiosInstance.interceptors.response.use(
|
||||
retries += 1;
|
||||
localStorage.setItem('sec_retries', retries);
|
||||
}
|
||||
if (error.response.data?.ErrorCode === 9) {
|
||||
if (LOGOUT_ON_SEC_ERROR_CODES.includes(error.response.data?.ErrorCode)) {
|
||||
localStorage.removeItem('access_token');
|
||||
localStorage.removeItem('gateway_endpoints');
|
||||
sessionStorage.clear();
|
||||
|
||||
Reference in New Issue
Block a user