Skip to content

[FEAT] 로그아웃/회원탈퇴 API 연동 - #176

Merged
ehye1 merged 4 commits into
developfrom
feat/web/175-logout-withdrawal-api-integration
Jul 14, 2026
Merged

[FEAT] 로그아웃/회원탈퇴 API 연동#176
ehye1 merged 4 commits into
developfrom
feat/web/175-logout-withdrawal-api-integration

Conversation

@ehye1

@ehye1 ehye1 commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

ISSUE 🔗

close #175



What is this PR? 🔍

로그아웃 및 회원탈퇴 API를 실제 서버와 연동하고, CodeRabbit 피드백을 반영해 세션 정리 로직을 공통화하고 에러 알림을 토스트로 교체했습니다.

배경

  • 기존 구조: 로그아웃/회원탈퇴 이후 세션을 정리하는 로직(clearAccessTokenqueryClient.clearrouter.replace)이 두 훅에 중복 구현되어 있었습니다.
  • 발생 문제: 세션 타임아웃, 토큰 리프레시 실패 등 다른 인증 흐름에서 재사용하기 어렵고, 회원탈퇴 실패 알림이 하드코딩된 한국어 window.alert으로 처리되어 i18n 미적용 상태였습니다.
  • 해결 방향: 공통 훅(useClearSession)으로 세션 정리 로직을 추출하고, 에러 알림을 컨테이너 계층의 AnimatedToast로 교체했습니다.

useClearSession

  • 변경 요약: clearAccessTokenqueryClient.clearrouter.replace(ROUTES.LOGIN)useClearSession 훅으로 추출했습니다.
  • 이유: 동일한 3단계 세션 정리 패턴이 use-logout.tsuse-withdraw.ts에 중복되어 있었으며, 향후 토큰 리프레시 실패 등 다른 인증 흐름에서도 재사용이 필요합니다.
  • 구현 방식: hooks/useClearSession.ts에 단일 훅으로 분리했습니다. 두 mutation 훅은 각각 useClearSession()으로 교체했습니다.

회원탈퇴 에러 처리

  • 변경 요약: use-withdraw.tsonError를 제거하고 SettingsWithdrawalContainer에서 AnimatedToast로 에러를 표시하도록 변경했습니다.
  • 이유: _queries 계층은 mutation 로직에만 집중해야 하며, 번역 컨텍스트(useTranslations)는 컨테이너 계층에 있어야 합니다. 하드코딩된 한국어 문자열로는 다국어 지원이 불가능했습니다.
  • 구현 방식: mutate(undefined, { onError }) 콜백으로 에러를 컨테이너에서 수신하고 isErrorToastOpen 상태로 AnimatedToast를 제어합니다. withdrawError 번역 키를 ko.json / en.json에 추가했습니다.

API 연동

  • 변경 요약: 로그아웃 및 회원탈퇴 mutation 훅을 추가하고, useSettingsProfile에서 useLogoutAction을 연결했습니다.
  • 이유: 기존에는 핸들러가 console.log로만 구현되어 있었습니다.
  • 구현 방식: 로그아웃은 서버 실패 시에도 클라이언트 세션을 파기해야 하므로 onSettled 사용. 회원탈퇴는 서버에서 실제 삭제가 완료된 경우에만 세션을 파기해야 하므로 onSuccess / onError 분리. isPending 가드로 중복 클릭을 방어했습니다. useSettingsProfileuseLogoutAction을 주입받아 profileActions.onLogout으로 노출합니다.



To Reviewers

  • 로그아웃 onSettled 선택 이유: 서버 실패 시에도 클라이언트 세션을 파기하는 것이 보안상 안전하다고 판단했습니다.
  • window.confirm은 기존 TODO 주석과 동일하게 임시 처리이며, 실제 확인 모달 교체는 별도 이슈에서 진행 예정입니다.
  • useClearSession 배치를 hooks/ 루트에 뒀는데, lib/auth/ 등 다른 위치가 더 적합하다면 피드백 부탁드립니다.
  • useSettingsProfile.ts가 diff에 포함된 이유: develop 머지 시 [FEAT] 인증 토큰 저장 방식 개선 및 라우트 접근 제어 추가 #179(프로필 조회 API 연동)와 conflict가 발생해, useLogoutAction import와 useMyProfile + LANGUAGE_REQUEST_MAP을 함께 유지하는 방향으로 해결했습니다.



Screenshot 📷



Test Checklist ✔

  • 로그아웃 버튼 클릭 → POST /api/v1/auth/logout 요청 확인 → /login 리다이렉트 확인
  • 로그아웃 후 뒤로가기 → /login으로 재진입 확인
  • Network에서 auth/logout URL 블락 후 로그아웃 → 서버 실패해도 /login 이동 확인
  • 회원탈퇴 버튼 클릭 → confirm 취소 → DELETE /api/v1/auth/withdraw 요청 없음 확인
  • 회원탈퇴 버튼 클릭 → confirm 확인 → DELETE /api/v1/auth/withdraw 요청 확인 → /login 리다이렉트 확인
  • 회원탈퇴 실패 시 → 화면 상단에 에러 토스트 노출 확인
  • 로그아웃/탈퇴 버튼 빠르게 두 번 클릭 → API 요청 1회만 발생 확인

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 13, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
timo Ready Ready Preview, Comment Jul 13, 2026 6:57pm

Request Review

@github-actions

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown

Timo Performance Report

Bundle Size — timo-web
라우트 크기 First Load JS
/[locale]/home 203.19 kB 🔴 409.08 kB
/[locale]/today 187.24 kB 🔴 393.12 kB
/[locale]/focus 159.35 kB 🔴 365.24 kB
/[locale]/settings/account 0 B 🟡 205.88 kB
/[locale]/settings 168.45 kB 🔴 374.33 kB
/[locale]/statistics 155.90 kB 🔴 361.78 kB
/[locale]/[...rest] 0 B 🟡 205.88 kB
/[locale]/login 215.53 kB 🔴 421.41 kB
/[locale]/oauth/callback 122.17 kB 🟡 328.06 kB
/[locale]/onboarding 234.95 kB 🔴 440.83 kB
/[locale] 121.55 kB 🟡 327.44 kB
/[locale]/policy 127.66 kB 🟡 333.54 kB

공유 번들: 205.88 kB
🟢 < 200kB  |  🟡 < 350kB  |  🔴 ≥ 350kB (First Load JS · gzip)

Lighthouse — timo-web
URL Perf A11y LCP CLS TBT
/en/home 🔴 64 🟢 95 🔴 15.5s 🟢 0.000 🟡 443ms
/en/today 🔴 60 🟢 95 🔴 15.3s 🟢 0.000 🟡 580ms
/en/focus 🔴 61 🟢 95 🔴 15.0s 🟢 0.000 🟡 517ms
/en/statistics 🔴 65 🟢 95 🔴 15.0s 🟢 0.000 🟡 397ms

Perf ≥ 70 / A11y ≥ 85 목표
LCP 🟢 < 2.5s 🟡 < 4s 🔴 ≥ 4s  |  CLS 🟢 < 0.1 🟡 < 0.25 🔴 ≥ 0.25  |  TBT 🟢 < 200ms 🟡 < 600ms 🔴 ≥ 600ms

Image Optimization — timo-web
파일 크기 포맷 상태
images/google-calendar.png 36.20 kB PNG ⚠️ 🟢
images/google-logo.png 26.79 kB PNG ⚠️ 🟢

총 2개 · 63.00 kB  |  🟢 < 200KB  |  🟡 < 500KB  |  🔴 ≥ 500KB
⚠️ 2개 파일 WebP/AVIF 변환 권장

측정 커밋: 248ad5a

@ehye1 ehye1 changed the title feat(web): 로그아웃/회원탈퇴 API 연동 (#175) [FEAT] 로그아웃/회원탈퇴 API 연동 Jul 13, 2026
@github-actions github-actions Bot added the ✨ Feature 새로운 기능(기능성) 구현 label Jul 13, 2026
@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

설정 화면의 로그아웃과 회원 탈퇴를 실제 React Query mutation 호출로 전환했습니다. 요청 중복을 방지하고, 로그아웃 종료 또는 회원 탈퇴 성공 시 세션을 정리하며, 탈퇴 실패 시 오류 토스트를 표시합니다.

Changes

설정 계정 작업

Layer / File(s) Summary
로그아웃 mutation 흐름
apps/timo-web/app/[locale]/(main)/settings/_hooks/useSettingsProfile.ts, apps/timo-web/app/[locale]/(main)/settings/_queries/use-logout.ts, apps/timo-web/hooks/useClearSession.ts
useSettingsProfile이 pending 상태를 확인한 뒤 useLogoutAction을 호출합니다. mutation 종료 시 액세스 토큰과 React Query 캐시를 정리하고 로그인 경로로 이동합니다.
회원 탈퇴 mutation 흐름
apps/timo-web/app/[locale]/(main)/settings/withdrawal/..., apps/timo-web/hooks/useClearSession.ts, apps/timo-web/messages/*.json
확인된 탈퇴 요청을 useWithdrawAction으로 실행하고 중복 제출을 차단합니다. 성공 시 세션을 정리하며 실패 시 한국어·영어 오류 메시지를 토스트로 표시합니다.

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
Loading

회원 탈퇴

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 표시
Loading

Possibly related PRs

  • Team-Timo/Timo-client#127: useSettingsProfile의 기존 로그아웃 TODO 흐름과 직접 연결된 설정 동작 변경입니다.
  • Team-Timo/Timo-client#152: useAuthStore와 로그인 리다이렉트를 포함한 인증 상태 흐름을 공유합니다.

Suggested labels: ♠️ 정민

Suggested reviewers: jjangminii, kimminna

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed #175의 로그아웃/회원탈퇴 API 연동, 세션 초기화, 리다이렉트 요구를 모두 충족한 것으로 보입니다.
Out of Scope Changes check ✅ Passed 요구사항과 무관한 변경은 보이지 않으며, 추가된 훅·문구·토스트는 모두 범위 안의 보조 수정입니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed 로그아웃/회원탈퇴 API 연동이라는 핵심 변경을 정확하고 간결하게 요약합니다.
Description check ✅ Passed 설명이 변경 내용인 로그아웃·회원탈퇴 API 연동, 세션 정리 공통화, 토스트 에러 처리와 일치합니다.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/web/175-logout-withdrawal-api-integration

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.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 317052f and 8faa640.

📒 Files selected for processing (4)
  • apps/timo-web/app/[locale]/(main)/settings/_hooks/useSettingsProfile.ts
  • apps/timo-web/app/[locale]/(main)/settings/_queries/use-logout.ts
  • apps/timo-web/app/[locale]/(main)/settings/withdrawal/_containers/SettingsWithdrawalContainer.tsx
  • apps/timo-web/app/[locale]/(main)/settings/withdrawal/_queries/use-withdraw.ts

Comment thread apps/timo-web/app/[locale]/(main)/settings/_queries/use-logout.ts
Comment thread apps/timo-web/app/[locale]/(main)/settings/withdrawal/_queries/use-withdraw.ts Outdated
- useClearSession 훅으로 clearAccessToken/queryClient.clear/router.replace 중복 로직을 추출했습니다
- use-logout, use-withdraw에서 useClearSession을 사용하도록 교체했습니다
- use-withdraw의 onError를 제거하고 SettingsWithdrawalContainer에서 AnimatedToast로 처리했습니다
- 탈퇴 에러 메시지를 ko.json, en.json에 추가했습니다

@kimminna kimminna left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

😍

@ehye1
ehye1 merged commit 91fea28 into develop Jul 14, 2026
14 checks passed
@kimminna kimminna mentioned this pull request Jul 14, 2026
@kimminna
kimminna deleted the feat/web/175-logout-withdrawal-api-integration branch July 14, 2026 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨ Feature 새로운 기능(기능성) 구현 ⏰ Timo-web Timo 웹 서비스 ♥️ 혜원 혜원양

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] 로그아웃/회원탈퇴 API 연동

2 participants