diff --git a/public/config.json b/public/config.json index 8bb0dab3b57..5e67902d4fe 100644 --- a/public/config.json +++ b/public/config.json @@ -22,5 +22,6 @@ "kasp_full_string": "Karunya Arogya Suraksha Padhathi", "sample_format_asset_import": "https://spreadsheets.google.com/feeds/download/spreadsheets/Export?key=11JaEhNHdyCHth4YQs_44YaRlP77Rrqe81VSEfg1glko&exportFormat=xlsx", "sample_format_external_result_import": "https://docs.google.com/spreadsheets/d/17VfgryA6OYSYgtQZeXU9mp7kNvLySeEawvnLBO_1nuE/export?format=csv&id=17VfgryA6OYSYgtQZeXU9mp7kNvLySeEawvnLBO_1nuE", - "enable_abdm": true + "enable_abdm": true, + "jwt_token_refresh_interval": 300000 } \ No newline at end of file diff --git a/src/Common/hooks/useConfig.ts b/src/Common/hooks/useConfig.ts index 7b956afec07..15e456ea571 100644 --- a/src/Common/hooks/useConfig.ts +++ b/src/Common/hooks/useConfig.ts @@ -68,6 +68,7 @@ export interface IConfig { * Env to toggle peacetime and wartime shifting */ wartime_shifting: boolean; + jwt_token_refresh_interval?: number; } const useConfig = () => { diff --git a/src/Providers/AuthUserProvider.tsx b/src/Providers/AuthUserProvider.tsx index 64027a17215..a64b38f630c 100644 --- a/src/Providers/AuthUserProvider.tsx +++ b/src/Providers/AuthUserProvider.tsx @@ -5,6 +5,7 @@ import routes from "../Redux/api"; import useQuery from "../Utils/request/useQuery"; import { LocalStorageKeys } from "../Common/constants"; import request from "../Utils/request/request"; +import useConfig from "../Common/hooks/useConfig"; interface Props { children: React.ReactNode; @@ -12,6 +13,7 @@ interface Props { } export default function AuthUserProvider({ children, unauthorized }: Props) { + const { jwt_token_refresh_interval } = useConfig(); const { res, data, loading } = useQuery(routes.currentUser, { refetchOnWindowFocus: false, prefetch: true, @@ -24,8 +26,11 @@ export default function AuthUserProvider({ children, unauthorized }: Props) { } updateRefreshToken(true); - setInterval(() => updateRefreshToken(), 5 * 60 * 1000); // TODO: move this interval to config.json - }, [data]); + setInterval( + () => updateRefreshToken(), + jwt_token_refresh_interval ?? 5 * 60 * 3000 + ); + }, [data, jwt_token_refresh_interval]); if (loading || !res) { return ;