-
Notifications
You must be signed in to change notification settings - Fork 0
[Fix/#53] 로그인 상태 확인 로직 수정 #154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Walkthrough공유 보드용 로그인 확인을 Changes
Sequence Diagram(s)sequenceDiagram
participant Sidebar as Sidebar 컴포넌트
participant AuthStore as useAuthStore
participant API as checkLogin 함수
participant Backend as 백엔드
Sidebar->>Sidebar: useEffect 트리거 (shareUri/사용자 변경)
alt shareUri 존재
Sidebar->>AuthStore: checkAuthForSharedBoard(shareUri)
else
Sidebar->>AuthStore: checkAuth()
end
AuthStore->>AuthStore: isCheckingAuth = true 설정
AuthStore->>API: checkLogin(shareUri) 호출
API->>Backend: GET /auth/check-login?shareUri=...
Backend-->>API: CheckLoginResponse 반환
API-->>AuthStore: 응답 전달
alt 성공
rect rgb(200,240,200)
AuthStore->>AuthStore: isLoggedIn, hasFetchedAuth, lastCheckedShareUri 업데이트
end
else 오류
rect rgb(240,200,200)
AuthStore->>AuthStore: isLoggedIn=false, hasFetchedAuth=true, lastCheckedShareUri 설정(오류 포함)
end
end
AuthStore->>AuthStore: isCheckingAuth = false 설정
AuthStore->>Sidebar: 상태 반영 (리렌더)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
|
✨ Storybook: 🔗 https://690458540424857aa71aec97-chmlsbszst.chromatic.com/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
src/apis/auth.tssrc/apis/config/endpoints.tssrc/components/ui/sidebar.tsxsrc/stores/useAuthStore.ts
🧰 Additional context used
🧬 Code graph analysis (2)
src/stores/useAuthStore.ts (1)
src/apis/auth.ts (2)
CheckLoginResponse(12-21)checkLogin(27-39)
src/apis/auth.ts (2)
src/lib/api.ts (1)
apiPost(39-45)src/apis/config/endpoints.ts (1)
API_ENDPOINTS(1-34)
🔇 Additional comments (2)
src/apis/config/endpoints.ts (1)
12-12: LGTM!새로운 엔드포인트가 올바르게 추가되었습니다.
src/apis/auth.ts (1)
12-21: LGTM!
CheckLoginResponse인터페이스가 명확하게 정의되었습니다. 응답 구조가validUser,invalidToken,owner필드를 포함하여 다양한 인증 상태를 처리할 수 있습니다.
| export const checkLogin = async ( | ||
| shareUri: string | ||
| ): Promise<CheckLoginResponse> => { | ||
| const response = await axiosInstance.post<CheckLoginResponse>( | ||
| API_ENDPOINTS.AUTH.CHECK_LOGIN, | ||
| null, | ||
| { | ||
| params: { shareUri }, | ||
| headers: { skipAuthRedirect: "true" }, | ||
| } | ||
| ); | ||
| return response.data; | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Search for skipAuthRedirect header usage and context
echo "=== Searching for skipAuthRedirect usage ==="
rg -n "skipAuthRedirect" -C 3
echo ""
echo "=== Searching for axios interceptor implementation ==="
rg -n "interceptor" -i -C 2
echo ""
echo "=== Searching for API_ENDPOINTS.AUTH ==="
rg -n "API_ENDPOINTS\.AUTH" -C 2Repository: First-Note-of-this-Year/Frontend
Length of output: 3667
🏁 Script executed:
#!/bin/bash
# Find API_ENDPOINTS definition
echo "=== Finding API_ENDPOINTS definition ==="
rg -n "API_ENDPOINTS" -A 15 | head -80
echo ""
echo "=== Looking for CHECK_LOGIN specifically ==="
rg -n "CHECK_LOGIN" -B 2 -A 2
echo ""
echo "=== Checking other read-only operations in auth ==="
rg -n "export const" src/apis/auth.tsRepository: First-Note-of-this-Year/Frontend
Length of output: 4354
🏁 Script executed:
#!/bin/bash
# Search for comments around checkLogin definition
echo "=== Full checkLogin function with context ==="
cat -n src/apis/auth.ts | sed -n '20,42p'
echo ""
echo "=== Searching for TODO or comments about HTTP methods ==="
rg -n "TODO|FIXME|NOTE" src/apis/auth.ts
echo ""
echo "=== Looking for backend API documentation or comments ==="
rg -n "/auth/check-login" -B 5 -A 5Repository: First-Note-of-this-Year/Frontend
Length of output: 1332
POST 메서드 사용 확인 필요
읽기 전용 로그인 상태 확인에 POST 메서드를 사용하는 것은 일반적이지 않습니다. skipAuthRedirect 헤더는 응답 인터셉터에서 401 에러 시 리다이렉트를 방지하도록 올바르게 구현되어 있으나, POST 메서드를 선택한 이유를 백엔드 API 명세에서 확인하세요.
현재 코드베이스의 다른 읽기 전용 작업들은 GET 메서드를 사용하고 있으므로, 이 엔드포인트가 특별히 POST를 요구하는지, 또는 GET으로 변경 가능한지 검토하시기 바랍니다.
🤖 Prompt for AI Agents
In src/apis/auth.ts around lines 27 to 39, the checkLogin function currently
uses axios.post for a read-only check which is inconsistent with other GET read
operations; verify the backend API spec to confirm whether this endpoint
requires POST, and if it does not, change the call to
axiosInstance.get<CheckLoginResponse>(API_ENDPOINTS.AUTH.CHECK_LOGIN, { params:
{ shareUri }, headers: { skipAuthRedirect: "true" } }) so parameters are sent as
query string and behavior stays identical; if the backend truly needs POST, add
a comment explaining why POST is required and keep the current implementation
but ensure params/body match the API contract.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
♻️ Duplicate comments (1)
src/components/ui/sidebar.tsx (1)
48-68: 공유 보드에서 내 보드로 전환 시 인증 재검증이 누락됨현재 로직은 이전 리뷰 코멘트에서 지적된 문제를 부분적으로만 해결했습니다:
동작하는 경우:
- 공유 보드 A → 공유 보드 B:
lastCheckedShareUri변경으로checkAuthForSharedBoard(B)호출 ✓- 내 보드 최초 방문:
!hasFetchedAuth이므로checkAuth()호출 ✓동작하지 않는 경우:
- 공유 보드 → 내 보드 전환 시,
hasFetchedAuth가 이미 true면 56번 라인의 조건(!hasFetchedAuth)이 거짓이 되어checkAuth()가 호출되지 않음 ✗이전 코멘트에서 언급했듯이 "내 보드와 공유 보드는 별도의 인증 컨텍스트"를 가지므로, 보드 타입이 변경될 때마다 해당 컨텍스트의 인증을 재확인해야 합니다. 특히 사용자가 공유 보드에서 활동하는 동안 세션이 만료되거나 인증 상태가 변경된 경우, 내 보드로 돌아올 때 이를 감지하지 못할 수 있습니다.
🔎 보드 타입 전환 시 재검증을 보장하는 수정안
useEffect(() => { if (isCheckingAuth) return; if (isSharedBoard && shareUri) { // 공유 보드 if (lastCheckedShareUri !== shareUri) { void checkAuthForSharedBoard(shareUri); } - } else if (!hasFetchedAuth) { + } else { // 내 보드 - void checkAuth(); + // 공유 보드에서 전환된 경우(lastCheckedShareUri가 존재) 또는 아직 체크하지 않은 경우 인증 확인 + if (lastCheckedShareUri || !hasFetchedAuth) { + void checkAuth(); + } } }, [ isSharedBoard, shareUri, checkAuth, checkAuthForSharedBoard, hasFetchedAuth, lastCheckedShareUri, isCheckingAuth, ]);이 수정안은
lastCheckedShareUri가 존재하는 경우(= 이전에 공유 보드를 방문했음)에도 내 보드의 인증을 재확인하도록 합니다.
🧹 Nitpick comments (1)
src/components/ui/sidebar.tsx (1)
60-68: useEffect 의존성 배열에서 중복 제거 권장
isSharedBoard는 46번 라인에서Boolean(shareUri)로 계산된 파생 값입니다.shareUri가 이미 의존성 배열에 포함되어 있으므로,isSharedBoard를 추가로 포함할 필요가 없습니다.🔎 중복 의존성 제거 제안
}, [ - isSharedBoard, shareUri, checkAuth, checkAuthForSharedBoard, hasFetchedAuth, lastCheckedShareUri, isCheckingAuth, ]);
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/components/ui/sidebar.tsxsrc/stores/useAuthStore.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/stores/useAuthStore.ts
Summary
Tasks
Summary by CodeRabbit
릴리스 노트
새로운 기능
개선
✏️ Tip: You can customize this high-level summary in your review settings.