Skip to content

Conversation

@hyesngy
Copy link
Member

@hyesngy hyesngy commented Dec 26, 2025

Summary

관련 있는 Issue를 태그해주세요. (e.g. > - #100)
closed #153
로그인 상태 확인 로직 수정

Tasks

  • 로그인 상태 확인 로직 수정

Summary by CodeRabbit

릴리스 노트

  • 새로운 기능

    • 공유 URI로 로그인 상태를 확인하는 기능 추가
    • 공유된 보드 접근 시 전용 인증 절차 지원
  • 개선

    • 중복 인증 확인 방지로 인증 흐름 최적화 및 성능 개선
    • 인증 처리의 안정성 향상 (공유 보드와 일반 보드 구분 처리)

✏️ Tip: You can customize this high-level summary in your review settings.

@hyesngy hyesngy self-assigned this Dec 26, 2025
@hyesngy hyesngy added the 🛠 Fix 버그 수정 label Dec 26, 2025
@hyesngy hyesngy linked an issue Dec 26, 2025 that may be closed by this pull request
@vercel
Copy link

vercel bot commented Dec 26, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
2025-seasonthon-team-80-fe Ready Ready Preview, Comment Dec 26, 2025 7:40am

@coderabbitai
Copy link

coderabbitai bot commented Dec 26, 2025

Walkthrough

공유 보드용 로그인 확인을 /auth/check-login 엔드포인트로 새로 구현하고, 이를 호출하는 checkLogin API와 공유보드 전용 인증 메서드 checkAuthForSharedBoard를 추가해 Sidebar의 인증 분기 흐름을 분리·조정합니다. (≤50단어)

Changes

Cohort / File(s) 변경 내용
인증 API
src/apis/auth.ts, src/apis/config/endpoints.ts
CheckLoginResponse 인터페이스 및 checkLogin(shareUri) 함수 추가; API_ENDPOINTS.AUTH.CHECK_LOGIN = "/auth/check-login" 추가
인증 상태 관리 (store)
src/stores/useAuthStore.ts
`lastCheckedShareUri: string
UI 통합 (Sidebar)
src/components/ui/sidebar.tsx
shareUri 존재 시 checkAuthForSharedBoard 호출로 분기; 기존 checkAuth와 병행 사용; 의존성 배열 확장 및 isCheckingAuth 기반 중복 검사 방지 로직 추가

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: 상태 반영 (리렌더)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

나는 토끼, 작은 키보드 위를 폴짝폴짝,
공유 링크 따라 로그인 길을 찾았네 🐇
체크-로그인 노선 새로 뚫었고,
인증의 발걸음은 부드럽게, 리듬을 타네,
깡총깡총 배포 꽃길을 달려라! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목이 로그인 상태 확인 로직 수정이라는 핵심 변경사항을 명확하게 설명하고 있습니다.
Description check ✅ Passed PR 설명이 필수 템플릿 섹션(Summary, Tasks)을 포함하고 있으며 관련 이슈(#153)를 명시하고 있습니다.
Linked Issues check ✅ Passed PR의 모든 코드 변경사항이 이슈 #153의 요구사항을 충족합니다: 새로운 CHECK_LOGIN 엔드포인트 추가, checkLogin 함수 구현, checkAuthForSharedBoard 메서드 추가로 /share에서 /check-login으로의 로직 변경을 완료했습니다.
Out of Scope Changes check ✅ Passed 모든 변경사항이 로그인 상태 확인 로직을 /check-login 엔드포인트로 변경하는 이슈 #153의 범위 내에 있습니다.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/#153

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.

@github-actions
Copy link

github-actions bot commented Dec 26, 2025

Copy link

@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: 4

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f81b574 and 1a9ebf4.

📒 Files selected for processing (4)
  • src/apis/auth.ts
  • src/apis/config/endpoints.ts
  • src/components/ui/sidebar.tsx
  • src/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 필드를 포함하여 다양한 인증 상태를 처리할 수 있습니다.

Comment on lines +27 to +39
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;
};
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 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 2

Repository: 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.ts

Repository: 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 5

Repository: 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.

Copy link

@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: 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

📥 Commits

Reviewing files that changed from the base of the PR and between 1a9ebf4 and d5de7c6.

📒 Files selected for processing (2)
  • src/components/ui/sidebar.tsx
  • src/stores/useAuthStore.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/stores/useAuthStore.ts

@hyesngy hyesngy merged commit 97e7c34 into develop Dec 26, 2025
6 checks passed
@hyesngy hyesngy deleted the fix/#153 branch December 26, 2025 07:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🛠 Fix 버그 수정

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Fix]: 로그인 상태 확인 로직 수정

2 participants