From d57b95c1272cf36a88c4e083950a1fe731a1739e Mon Sep 17 00:00:00 2001 From: yseokkkkkk Date: Thu, 18 Jul 2024 14:46:25 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20oauth=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/OauthCallback.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/utils/OauthCallback.js b/src/utils/OauthCallback.js index 0a98aa6..c3c7955 100644 --- a/src/utils/OauthCallback.js +++ b/src/utils/OauthCallback.js @@ -9,6 +9,7 @@ const OauthCallback = () => { const [error, setError] = useState(null); const { setRefreshToken, setAccessToken } = useTokenStore(); const navigate = useNavigate(); + const [retry, setRetry] = useState(0); const getKakaoToken = useCallback(async (code) => { try { @@ -58,6 +59,7 @@ const OauthCallback = () => { } catch (error) { setIsError(true); setError(error); + setRetry((prev) => prev + 1); } finally { setIsLoading(false); } @@ -70,8 +72,9 @@ const OauthCallback = () => { ]); useEffect(() => { + if (retry > 2) navigate("/login", { replace: true }); fetchTokens(); - }, [fetchTokens]); + }, [fetchTokens, retry, navigate]); if (isLoading) return
Loading...
; if (isError) return
Error: {error.message}
;