mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-22 06:15:47 +00:00
Merge branch 'feat/FE/refresh-user-session' into 'development'
[FEAT/FE] Refresh user session See merge request mbugroup/lti-web-client!127
This commit is contained in:
@@ -5,6 +5,7 @@ import useSWR from 'swr';
|
||||
|
||||
import { useAuth } from '@/services/hooks/useAuth';
|
||||
import { httpClientFetcher, SWRHttpKey } from '@/services/http/client';
|
||||
import { AuthApi } from '@/services/api/auth';
|
||||
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
||||
import { BaseApiResponse, GetMeResponse } from '@/types/api/api-general';
|
||||
import { AxiosError } from 'axios';
|
||||
@@ -55,6 +56,17 @@ const RequireAuth = ({ children }: RequireAuthProps) => {
|
||||
setIsLoadingUser(isLoadingUserResponse);
|
||||
}, [isLoadingUserResponse]);
|
||||
|
||||
useEffect(() => {
|
||||
const interval = setInterval(
|
||||
async () => {
|
||||
await AuthApi.refresh();
|
||||
},
|
||||
13 * 60 * 1000
|
||||
);
|
||||
|
||||
return () => clearInterval(interval);
|
||||
}, []);
|
||||
|
||||
if (
|
||||
(isLoadingUserResponse && !userResponse && !userErrorResponse) ||
|
||||
(!userResponse && !userErrorResponse)
|
||||
|
||||
Reference in New Issue
Block a user