Skip to content

Commit

Permalink
whitelisted jwt_token_refresh_interval (#6418)
Browse files Browse the repository at this point in the history
* whitelisted jwt_token_refresh_interval

* removed todo
  • Loading branch information
kshitijv256 authored Oct 9, 2023
1 parent 10179d3 commit a21bc89
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion public/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
1 change: 1 addition & 0 deletions src/Common/hooks/useConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export interface IConfig {
* Env to toggle peacetime and wartime shifting
*/
wartime_shifting: boolean;
jwt_token_refresh_interval?: number;
}

const useConfig = () => {
Expand Down
9 changes: 7 additions & 2 deletions src/Providers/AuthUserProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ 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;
unauthorized: React.ReactNode;
}

export default function AuthUserProvider({ children, unauthorized }: Props) {
const { jwt_token_refresh_interval } = useConfig();
const { res, data, loading } = useQuery(routes.currentUser, {
refetchOnWindowFocus: false,
prefetch: true,
Expand All @@ -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 <Loading />;
Expand Down

0 comments on commit a21bc89

Please sign in to comment.