[FEAT] 로그아웃/회원탈퇴 API 연동 - #176
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Timo Performance ReportBundle Size — timo-web
Lighthouse — timo-web
Image Optimization — timo-web
측정 커밋: |
Walkthrough설정 화면의 로그아웃과 회원 탈퇴를 실제 React Query mutation 호출로 전환했습니다. 요청 중복을 방지하고, 로그아웃 종료 또는 회원 탈퇴 성공 시 세션을 정리하며, 탈퇴 실패 시 오류 토스트를 표시합니다. Changes설정 계정 작업
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)로그아웃sequenceDiagram
participant Profile as useSettingsProfile
participant Action as useLogoutAction
participant API as logout
participant Session as useClearSession
participant Router
Profile->>Action: logoutMutate()
Action->>API: 로그아웃 요청
API-->>Action: mutation 종료
Action->>Session: clearSession()
Session->>Router: 토큰·캐시 정리 후 로그인 경로로 replace
회원 탈퇴sequenceDiagram
participant Container as SettingsWithdrawalContainer
participant Action as useWithdrawAction
participant API as withdraw
participant Session as useClearSession
participant Toast as AnimatedToast
Container->>Action: 확인 후 withdrawMutate()
Action->>API: 탈퇴 요청
API-->>Action: 성공 또는 오류 응답
Action->>Session: 성공 시 clearSession()
Action-->>Container: 오류 시 onError
Container->>Toast: withdrawError 표시
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/timo-web/app/`[locale]/(main)/settings/_queries/use-logout.ts:
- Around line 17-21: Extract the duplicated session cleanup into a reusable auth
utility or hook that performs clearAccessToken, queryClient.clear, and
router.replace(ROUTES.LOGIN) in that order. In
apps/timo-web/app/[locale]/(main)/settings/_queries/use-logout.ts lines 17-21,
replace the onSettled cleanup with the shared utility call; make the same
replacement in
apps/timo-web/app/[locale]/(main)/settings/withdrawal/_queries/use-withdraw.ts
lines 17-21 within onSuccess, preserving existing callback behavior.
In
`@apps/timo-web/app/`[locale]/(main)/settings/withdrawal/_queries/use-withdraw.ts:
- Around line 22-26: useWithdraw의 onError에서 하드코딩된 한국어 알림을 제거하고, 번역이 가능한 컨테이너
계층에서 탈퇴 mutation의 오류를 처리하도록 변경하세요. 컨테이너의 mutate 호출에 onError 콜백을 전달하거나
isError/error 상태를 관찰해 useTranslations로 현지화된 메시지를 표시하고, _queries 계층은 mutation 로직만
담당하게 유지하세요.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 9b3000d4-3969-4f4a-a534-85ef7d6afd3a
📒 Files selected for processing (4)
apps/timo-web/app/[locale]/(main)/settings/_hooks/useSettingsProfile.tsapps/timo-web/app/[locale]/(main)/settings/_queries/use-logout.tsapps/timo-web/app/[locale]/(main)/settings/withdrawal/_containers/SettingsWithdrawalContainer.tsxapps/timo-web/app/[locale]/(main)/settings/withdrawal/_queries/use-withdraw.ts
- useClearSession 훅으로 clearAccessToken/queryClient.clear/router.replace 중복 로직을 추출했습니다 - use-logout, use-withdraw에서 useClearSession을 사용하도록 교체했습니다 - use-withdraw의 onError를 제거하고 SettingsWithdrawalContainer에서 AnimatedToast로 처리했습니다 - 탈퇴 에러 메시지를 ko.json, en.json에 추가했습니다
ISSUE 🔗
close #175
What is this PR? 🔍
로그아웃 및 회원탈퇴 API를 실제 서버와 연동하고, CodeRabbit 피드백을 반영해 세션 정리 로직을 공통화하고 에러 알림을 토스트로 교체했습니다.
배경
clearAccessToken→queryClient.clear→router.replace)이 두 훅에 중복 구현되어 있었습니다.window.alert으로 처리되어 i18n 미적용 상태였습니다.useClearSession)으로 세션 정리 로직을 추출하고, 에러 알림을 컨테이너 계층의AnimatedToast로 교체했습니다.useClearSession
clearAccessToken→queryClient.clear→router.replace(ROUTES.LOGIN)를useClearSession훅으로 추출했습니다.use-logout.ts와use-withdraw.ts에 중복되어 있었으며, 향후 토큰 리프레시 실패 등 다른 인증 흐름에서도 재사용이 필요합니다.hooks/useClearSession.ts에 단일 훅으로 분리했습니다. 두 mutation 훅은 각각useClearSession()으로 교체했습니다.회원탈퇴 에러 처리
use-withdraw.ts의onError를 제거하고SettingsWithdrawalContainer에서AnimatedToast로 에러를 표시하도록 변경했습니다._queries계층은 mutation 로직에만 집중해야 하며, 번역 컨텍스트(useTranslations)는 컨테이너 계층에 있어야 합니다. 하드코딩된 한국어 문자열로는 다국어 지원이 불가능했습니다.mutate(undefined, { onError })콜백으로 에러를 컨테이너에서 수신하고isErrorToastOpen상태로AnimatedToast를 제어합니다.withdrawError번역 키를ko.json/en.json에 추가했습니다.API 연동
useSettingsProfile에서useLogoutAction을 연결했습니다.console.log로만 구현되어 있었습니다.onSettled사용. 회원탈퇴는 서버에서 실제 삭제가 완료된 경우에만 세션을 파기해야 하므로onSuccess/onError분리.isPending가드로 중복 클릭을 방어했습니다.useSettingsProfile은useLogoutAction을 주입받아profileActions.onLogout으로 노출합니다.To Reviewers
onSettled선택 이유: 서버 실패 시에도 클라이언트 세션을 파기하는 것이 보안상 안전하다고 판단했습니다.window.confirm은 기존 TODO 주석과 동일하게 임시 처리이며, 실제 확인 모달 교체는 별도 이슈에서 진행 예정입니다.useClearSession배치를hooks/루트에 뒀는데,lib/auth/등 다른 위치가 더 적합하다면 피드백 부탁드립니다.useSettingsProfile.ts가 diff에 포함된 이유: develop 머지 시 [FEAT] 인증 토큰 저장 방식 개선 및 라우트 접근 제어 추가 #179(프로필 조회 API 연동)와 conflict가 발생해,useLogoutActionimport와useMyProfile+LANGUAGE_REQUEST_MAP을 함께 유지하는 방향으로 해결했습니다.Screenshot 📷
Test Checklist ✔
POST /api/v1/auth/logout요청 확인 →/login리다이렉트 확인/login으로 재진입 확인auth/logoutURL 블락 후 로그아웃 → 서버 실패해도/login이동 확인DELETE /api/v1/auth/withdraw요청 없음 확인DELETE /api/v1/auth/withdraw요청 확인 →/login리다이렉트 확인