Skip to content

[refactor] auth restore 단계 당기기#202

Merged
ff1451 merged 1 commit intodevelopfrom
201-refactor-로그인-로직-개편
Mar 20, 2026

Hidden character warning

The head ref may contain hidden characters: "201-refactor-\ub85c\uadf8\uc778-\ub85c\uc9c1-\uac1c\ud3b8"
Merged

[refactor] auth restore 단계 당기기#202
ff1451 merged 1 commit intodevelopfrom
201-refactor-로그인-로직-개편

Conversation

@ff1451
Copy link
Copy Markdown
Collaborator

@ff1451 ff1451 commented Mar 20, 2026

Summary by CodeRabbit

릴리스 노트

  • 리팩토링
    • 인증 상태 관리 체계를 개선했습니다. 이제 더 정확한 인증 상태 추적(미확인/인증됨/미인증)으로 앱이 더 안정적으로 동작합니다.
    • 세션 복원 프로세스를 앱 초기화 초반으로 이동했습니다. 이를 통해 인증 초기화가 더 효율적으로 처리됩니다.
    • 라우팅 구조를 정리하여 앱의 로딩 상태 처리가 개선되었습니다.

@ff1451 ff1451 self-assigned this Mar 20, 2026
@ff1451 ff1451 linked an issue Mar 20, 2026 that may be closed by this pull request
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 20, 2026

Walkthrough

AuthGuard 컴포넌트를 제거하고 Suspense/SentryRoutes 래핑 구조를 재정렬했습니다. 인증 상태 관리를 boolean의 isAuthenticated에서 AuthStatus 문자열 타입('unknown' | 'authenticated' | 'anonymous')으로 전환하고, main.tsx에서 라우팅 렌더링 전에 세션 복구 로직을 실행하도록 변경했습니다. ProtectedRoute와 PublicRoute가 새로운 authStatus 기반 조건으로 동작하도록 수정되었습니다.

Possibly related PRs

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR 제목이 변경 사항의 핵심을 명확하게 나타냅니다. AuthGuard 제거 및 인증 초기화 로직을 main.tsx로 이동한 리팩토링의 주요 의도('auth restore 단계 당기기')를 잘 반영합니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 201-refactor-로그인-로직-개편
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/components/auth/PublicRoute.tsx (1)

5-11: ⚠️ Potential issue | 🟡 Minor

unknown 상태도 막아주세요.

지금은 세션 복구 중인 unknown 상태에서도 바로 <Outlet />을 열어서, 로그인된 사용자가 새로고침하면 로그인/회원가입 화면이 잠깐 보였다가 /home으로 이동하는 플래시가 생깁니다. ProtectedRoute처럼 여기서도 로딩 fallback을 먼저 보여주는 쪽이 안전합니다.

제안
 function PublicRoute() {
   const authStatus = useAuthStore((state) => state.authStatus);

+  if (authStatus === 'unknown') {
+    return <RouteLoadingFallback fullScreen />;
+  }
+
   if (authStatus === 'authenticated') {
     return <Navigate to="/home" replace />;
   }

   return <Outlet />;
 }

상단에 RouteLoadingFallback import도 하나 추가해주세요.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/auth/PublicRoute.tsx` around lines 5 - 11, PublicRoute
currently renders <Outlet /> during the 'unknown' authStatus which causes a
flash; update the component so that when useAuthStore((s)=>s.authStatus) ===
'unknown' it returns <RouteLoadingFallback /> (add an import for
RouteLoadingFallback at the top), otherwise keep the existing checks (if
'authenticated' return <Navigate to="/home" replace />; else return <Outlet />).
Ensure you reference useAuthStore and authStatus inside PublicRoute and add the
RouteLoadingFallback import.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/main.tsx`:
- Around line 22-24: The current bootstrap only calls startSessionRestore() if
window.location.pathname !== SERVER_ERROR_PATH at load, so entering or
refreshing on /server-error permanently skips session restoration and leaves
authStatus as unknown; change this to guarantee restoration once the app
navigates off /server-error by adding a one-time route watcher (e.g., a
history/location listener or a useEffect tied to the router) that calls
startSessionRestore() (or initialize() completion) the first time pathname !==
SERVER_ERROR_PATH after startup; ensure the watcher cleans itself up after
invoking startSessionRestore() so it only runs once and that ProtectedRoute and
useErrorPageHomeNavigation see a resolved authStatus.

---

Outside diff comments:
In `@src/components/auth/PublicRoute.tsx`:
- Around line 5-11: PublicRoute currently renders <Outlet /> during the
'unknown' authStatus which causes a flash; update the component so that when
useAuthStore((s)=>s.authStatus) === 'unknown' it returns <RouteLoadingFallback
/> (add an import for RouteLoadingFallback at the top), otherwise keep the
existing checks (if 'authenticated' return <Navigate to="/home" replace />; else
return <Outlet />). Ensure you reference useAuthStore and authStatus inside
PublicRoute and add the RouteLoadingFallback import.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4685a4f7-ab6c-40ee-9e71-243c9c28ac54

📥 Commits

Reviewing files that changed from the base of the PR and between 0dc8b9c and 9871941.

📒 Files selected for processing (7)
  • src/App.tsx
  • src/components/auth/AuthGuard.tsx
  • src/components/auth/ProtectedRoute.tsx
  • src/components/auth/PublicRoute.tsx
  • src/main.tsx
  • src/stores/authStore.ts
  • src/utils/hooks/useErrorPageHomeNavigation.ts
💤 Files with no reviewable changes (1)
  • src/components/auth/AuthGuard.tsx

Comment thread src/main.tsx
Comment on lines +22 to +24
if (window.location.pathname !== SERVER_ERROR_PATH) {
startSessionRestore();
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

/server-error에서 시작하면 세션 복구가 아예 시작되지 않습니다.

Line 22 분기는 부트스트랩 시점에 한 번만 평가됩니다. 그래서 사용자가 /server-error로 직접 진입하거나 그 페이지에서 새로고침하면 initialize()가 끝까지 호출되지 않고, 이후 SPA 내비게이션으로 다른 라우트로 이동해도 authStatus가 계속 unknown에 머뭅니다. 그 상태에서는 ProtectedRoute가 로딩에 갇히고, useErrorPageHomeNavigation도 항상 /로 보내게 됩니다. 초기 URL만 기준으로 스킵하지 말고, 적어도 /server-error를 벗어나는 첫 시점에는 세션 복구가 보장되게 해주세요.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main.tsx` around lines 22 - 24, The current bootstrap only calls
startSessionRestore() if window.location.pathname !== SERVER_ERROR_PATH at load,
so entering or refreshing on /server-error permanently skips session restoration
and leaves authStatus as unknown; change this to guarantee restoration once the
app navigates off /server-error by adding a one-time route watcher (e.g., a
history/location listener or a useEffect tied to the router) that calls
startSessionRestore() (or initialize() completion) the first time pathname !==
SERVER_ERROR_PATH after startup; ensure the watcher cleans itself up after
invoking startSessionRestore() so it only runs once and that ProtectedRoute and
useErrorPageHomeNavigation see a resolved authStatus.

@ff1451 ff1451 merged commit fe3ba76 into develop Mar 20, 2026
2 checks passed
@ff1451 ff1451 deleted the 201-refactor-로그인-로직-개편 branch April 7, 2026 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[refactor] 로그인 로직 개편

1 participant