Fix race condition while loading metadata on sign in (#9027)

This commit is contained in:
Charles Bochet
2024-12-11 18:56:02 +01:00
committed by GitHub
parent 183fd877c4
commit 90c26643a8
9 changed files with 89 additions and 33 deletions

View File

@ -3,7 +3,9 @@ import { useNavigate, useSearchParams } from 'react-router-dom';
import { useAuth } from '@/auth/hooks/useAuth';
import { useIsLogged } from '@/auth/hooks/useIsLogged';
import { isAppWaitingForFreshObjectMetadataState } from '@/object-metadata/states/isAppWaitingForFreshObjectMetadataState';
import { AppPath } from '@/types/AppPath';
import { useSetRecoilState } from 'recoil';
export const VerifyEffect = () => {
const [searchParams] = useSearchParams();
@ -14,11 +16,16 @@ export const VerifyEffect = () => {
const { verify } = useAuth();
const setIsAppWaitingForFreshObjectMetadata = useSetRecoilState(
isAppWaitingForFreshObjectMetadataState,
);
useEffect(() => {
const getTokens = async () => {
if (!loginToken) {
navigate(AppPath.SignInUp);
} else {
setIsAppWaitingForFreshObjectMetadata(true);
await verify(loginToken);
}
};