|
|
|
@@ -12,7 +12,7 @@ export const predictUsageCount = 'predictUsageCount' |
|
|
|
export const windowCount = 'windowCount' |
|
|
|
import {useNavigate} from "react-router-dom"; |
|
|
|
import {useDispatch} from "react-redux"; |
|
|
|
import { REFRESH_TOKEN } from 'utils/ApiPathConst'; |
|
|
|
import { LOGOUT, REFRESH_TOKEN } from 'utils/ApiPathConst'; |
|
|
|
import { getMessage } from 'utils/getI18nMessage'; |
|
|
|
|
|
|
|
// Guard so we only register interceptors once (ThemeRoutes re-renders add duplicate handlers otherwise) |
|
|
|
@@ -22,7 +22,7 @@ let expiredAlertShownInMemory = false; |
|
|
|
|
|
|
|
/** Login / public auth endpoints must not trigger token refresh or session-expiry reload. */ |
|
|
|
const isPublicAuthRequest = (reqUrl) => |
|
|
|
reqUrl.includes('/login'); |
|
|
|
reqUrl.includes('/login') || reqUrl.includes('/refresh-token') || reqUrl.includes('/logout'); |
|
|
|
|
|
|
|
/** Clear stale session-expiry flag so a new login attempt can show its own error dialog. */ |
|
|
|
export const clearExpiredSessionAlert = () => { |
|
|
|
@@ -96,6 +96,11 @@ export const isTokenValid = () =>{ |
|
|
|
// ** Handle User Logout |
|
|
|
export const handleLogoutFunction = () => { |
|
|
|
return dispatch => { |
|
|
|
const refreshToken = localStorage.getItem('refreshToken') |
|
|
|
if (refreshToken) { |
|
|
|
axios.post(`${apiPath}${LOGOUT}`, { refreshToken }).catch(() => {}) |
|
|
|
} |
|
|
|
|
|
|
|
dispatch({ |
|
|
|
type: 'LOGOUT', |
|
|
|
accessToken: null, |
|
|
|
|