diff --git a/src/auth/index.js b/src/auth/index.js index 06f94af4..7ad7c48d 100644 --- a/src/auth/index.js +++ b/src/auth/index.js @@ -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, diff --git a/src/utils/ApiPathConst.js b/src/utils/ApiPathConst.js index c25ac012..843dcd97 100644 --- a/src/utils/ApiPathConst.js +++ b/src/utils/ApiPathConst.js @@ -5,6 +5,7 @@ import { // GET request export const REFRESH_TOKEN = "/refresh-token" +export const LOGOUT = "/logout" export const CHANGE_PASSWORD_PATH = "/user/change-password" export const GET_SYS_PARAMS = apiPath+'/settings';