From a5349df42ca7f86d24a6df781f25defe9b96cbf1 Mon Sep 17 00:00:00 2001 From: kimminna Date: Wed, 15 Jul 2026 01:04:41 +0900 Subject: [PATCH 1/2] =?UTF-8?q?feat(web):=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20?= =?UTF-8?q?=EA=B0=80=EB=93=9C=EC=97=90=EC=84=9C=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=EC=9E=90=20=EC=8B=9C=EA=B0=84=EB=8C=80=20=EA=B0=90=EC=A7=80=20?= =?UTF-8?q?=ED=9B=84=20=EC=84=9C=EB=B2=84=20=EB=8F=99=EA=B8=B0=ED=99=94=20?= =?UTF-8?q?(#199)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - accessToken 확보 시 Intl.DateTimeFormat으로 IANA 시간대를 감지해 useUpdateTimezone PATCH를 호출하도록 추가했습니다 - syncedTokenRef로 같은 토큰에 대해 중복 PATCH가 발생하지 않도록 했습니다 --- apps/timo-web/providers/auth/AuthGuardProvider.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/apps/timo-web/providers/auth/AuthGuardProvider.tsx b/apps/timo-web/providers/auth/AuthGuardProvider.tsx index 5a142b85..0154b46b 100644 --- a/apps/timo-web/providers/auth/AuthGuardProvider.tsx +++ b/apps/timo-web/providers/auth/AuthGuardProvider.tsx @@ -1,7 +1,8 @@ "use client"; -import { useEffect } from "react"; +import { useEffect, useRef } from "react"; +import { useUpdateTimezone } from "@/api/generated/endpoints/user/user"; import { ROUTES } from "@/constants/routes"; import { useRouter } from "@/i18n/navigation"; import { useAuthStore } from "@/stores/auth/useAuthStore"; @@ -14,6 +15,8 @@ export const AuthGuardProvider = ({ children }: AuthGuardProviderProps) => { const accessToken = useAuthStore((state) => state.accessToken); const isInitialized = useAuthStore((state) => state.isInitialized); const router = useRouter(); + const { mutate: updateTimezone } = useUpdateTimezone(); + const syncedTokenRef = useRef(null); useEffect(() => { if (isInitialized && !accessToken) { @@ -21,6 +24,14 @@ export const AuthGuardProvider = ({ children }: AuthGuardProviderProps) => { } }, [accessToken, isInitialized, router]); + useEffect(() => { + if (!accessToken || syncedTokenRef.current === accessToken) return; + + syncedTokenRef.current = accessToken; + const zoneId = Intl.DateTimeFormat().resolvedOptions().timeZone; + updateTimezone({ data: { zoneId } }); + }, [accessToken, updateTimezone]); + if (!isInitialized || !accessToken) return null; return <>{children}; From 8806763e6ea66612ace3598c772c4927625b2088 Mon Sep 17 00:00:00 2001 From: kimminna Date: Wed, 15 Jul 2026 01:53:02 +0900 Subject: [PATCH 2/2] =?UTF-8?q?fix(web):=20=EC=83=88=EB=A1=9C=EA=B3=A0?= =?UTF-8?q?=EC=B9=A8=20=EC=8B=9C=20=ED=83=80=EC=9E=84=EC=A1=B4=20=EB=8F=99?= =?UTF-8?q?=EA=B8=B0=ED=99=94=20=EC=9E=AC=ED=98=B8=EC=B6=9C=EB=90=98?= =?UTF-8?q?=EB=8D=98=20=EB=AC=B8=EC=A0=9C=20=EC=88=98=EC=A0=95=20(#199)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 타임존 동기화 로직을 로그인 가드(AuthGuardProvider)에서 OAuth 콜백(OauthCallbackContainer)으로 옮겼습니다 - accessToken이 localStorage에 남아있는 상태로 새로고침될 때마다 컴포넌트가 리마운트되어 동기화 API가 매번 재호출되던 문제를 해결했습니다 - 이제 실제 로그인이 성공하는 시점에만 서버로 타임존이 동기화됩니다 --- .../_containers/OauthCallbackContainer.tsx | 15 ++++++++++++++- .../timo-web/providers/auth/AuthGuardProvider.tsx | 13 +------------ 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/apps/timo-web/app/[locale]/oauth/callback/_containers/OauthCallbackContainer.tsx b/apps/timo-web/app/[locale]/oauth/callback/_containers/OauthCallbackContainer.tsx index 51911d94..c727f4b6 100644 --- a/apps/timo-web/app/[locale]/oauth/callback/_containers/OauthCallbackContainer.tsx +++ b/apps/timo-web/app/[locale]/oauth/callback/_containers/OauthCallbackContainer.tsx @@ -4,6 +4,7 @@ import { useSearchParams } from "next/navigation"; import { useEffect, useRef } from "react"; import { useToken } from "@/api/generated/endpoints/auth/auth"; +import { useUpdateTimezone } from "@/api/generated/endpoints/user/user"; import { ROUTES } from "@/constants/routes"; import { useRouter } from "@/i18n/navigation"; import { useAuthStore } from "@/stores/auth/useAuthStore"; @@ -16,6 +17,7 @@ export const OauthCallbackContainer = () => { (state) => state.setOnboardingCompleted, ); const { mutate } = useToken(); + const { mutate: updateTimezone } = useUpdateTimezone(); const hasRequested = useRef(false); useEffect(() => { @@ -36,6 +38,10 @@ export const OauthCallbackContainer = () => { } setAccessToken(data.accessToken); setOnboardingCompleted(data.user.onboardingCompleted); + + const zoneId = Intl.DateTimeFormat().resolvedOptions().timeZone; + updateTimezone({ data: { zoneId } }); + router.replace(data.isNewUser ? ROUTES.ONBOARDING : ROUTES.HOME); }, onError: () => { @@ -43,7 +49,14 @@ export const OauthCallbackContainer = () => { }, }, ); - }, [code, mutate, router, setAccessToken, setOnboardingCompleted]); + }, [ + code, + mutate, + router, + setAccessToken, + setOnboardingCompleted, + updateTimezone, + ]); return null; }; diff --git a/apps/timo-web/providers/auth/AuthGuardProvider.tsx b/apps/timo-web/providers/auth/AuthGuardProvider.tsx index 0154b46b..5a142b85 100644 --- a/apps/timo-web/providers/auth/AuthGuardProvider.tsx +++ b/apps/timo-web/providers/auth/AuthGuardProvider.tsx @@ -1,8 +1,7 @@ "use client"; -import { useEffect, useRef } from "react"; +import { useEffect } from "react"; -import { useUpdateTimezone } from "@/api/generated/endpoints/user/user"; import { ROUTES } from "@/constants/routes"; import { useRouter } from "@/i18n/navigation"; import { useAuthStore } from "@/stores/auth/useAuthStore"; @@ -15,8 +14,6 @@ export const AuthGuardProvider = ({ children }: AuthGuardProviderProps) => { const accessToken = useAuthStore((state) => state.accessToken); const isInitialized = useAuthStore((state) => state.isInitialized); const router = useRouter(); - const { mutate: updateTimezone } = useUpdateTimezone(); - const syncedTokenRef = useRef(null); useEffect(() => { if (isInitialized && !accessToken) { @@ -24,14 +21,6 @@ export const AuthGuardProvider = ({ children }: AuthGuardProviderProps) => { } }, [accessToken, isInitialized, router]); - useEffect(() => { - if (!accessToken || syncedTokenRef.current === accessToken) return; - - syncedTokenRef.current = accessToken; - const zoneId = Intl.DateTimeFormat().resolvedOptions().timeZone; - updateTimezone({ data: { zoneId } }); - }, [accessToken, updateTimezone]); - if (!isInitialized || !accessToken) return null; return <>{children};