Conversation
Walkthrough
Possibly related PRs
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 Tip CodeRabbit can use TruffleHog to scan for secrets in your code with verification capabilities.Add a TruffleHog config file (e.g. trufflehog-config.yml, trufflehog.yml) to your project to customize detectors and scanning behavior. The tool runs only when a config file is present. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/hooks/useLogout.ts (1)
20-29: 성공/실패 핸들러의 후처리 중복은 공통 함수로 합쳐두면 유지보수가 쉬워집니다.현재
clearCookies → queryClient.clear → router.push('/')가 두 군데 중복되어 있어, 이후 변경 시 한쪽만 수정되는 리스크가 있습니다.♻️ 제안 diff
return useMutation({ mutationFn: logout, + onSuccess: () => { + handleLogoutComplete(); + }, + onError: () => { + handleLogoutComplete(); + }, + }); + + function handleLogoutComplete() { + clearCookies(); + queryClient.clear(); + router.push('/'); + } - onSuccess: () => { - clearCookies(); - queryClient.clear(); - router.push('/'); - }, - onError: () => { - clearCookies(); - queryClient.clear(); - router.push('/'); - }, - });🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/hooks/useLogout.ts` around lines 20 - 29, Extract the duplicated cleanup logic from the onSuccess and onError handlers into a single reusable function (e.g., handleLogoutCleanup) and call that function from both onSuccess and onError; specifically move clearCookies(), queryClient.clear(), and router.push('/') into the new function and replace the inline sequences in the existing onSuccess and onError handlers with a call to that function so future changes are made in one place.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/hooks/useLogout.ts`:
- Around line 20-29: Extract the duplicated cleanup logic from the onSuccess and
onError handlers into a single reusable function (e.g., handleLogoutCleanup) and
call that function from both onSuccess and onError; specifically move
clearCookies(), queryClient.clear(), and router.push('/') into the new function
and replace the inline sequences in the existing onSuccess and onError handlers
with a call to that function so future changes are made in one place.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 323ab0e3-1c4c-4d52-9842-fca39e2e234b
📒 Files selected for processing (1)
src/hooks/useLogout.ts
관련 이슈
PR 설명
원인
document.cookie)에서 설정했으나 클라이언트(useLogout.ts)에 쿠키 삭제 로직이 없어서 실패middleware에서 dev일 경우 쿠키 검사를 건너뛰도록 하여 동작이 잘 됐던 것으로 추정변경 사항
useLogout에서 로그아웃 성공/실패 시 클라이언트에서 직접deleteCookieUtil로 쿠키 삭제하도록 수정