feat: 프로필 설정 로그아웃/팀 탈퇴 기능 추가 (#63) - #65
Conversation
- 워크스페이스 헤더/사이드바 로그아웃 버튼 연결 (useLogout 공용 훅) - 팀 탈퇴 기능 추가 (workspace_members 하드 딜리트, role='member' 조건으로 원자적 처리)
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthrough워크스페이스 멤버 탈퇴 서버 액션과 프로필 UI가 추가되었습니다. 헤더와 사이드바에 로그아웃 기능이 연결되었고, 인증 페이지 라우팅이 프로필 상태에 따라 변경되었습니다. Changes워크스페이스 프로필 및 멤버 관리
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Member
participant MemberProfileForm
participant leaveWorkspace
participant Supabase
participant Workspaces
Member->>MemberProfileForm: 팀 탈퇴 확인
MemberProfileForm->>leaveWorkspace: workspaceId 전달
leaveWorkspace->>Supabase: 멤버 레코드 삭제
Supabase-->>leaveWorkspace: 삭제 결과 반환
leaveWorkspace-->>MemberProfileForm: 성공 또는 오류
MemberProfileForm->>Workspaces: 성공 시 /workspaces 이동
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 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 `@src/entities/workspace-member/api/leave-workspace.ts`:
- Around line 3-50: Update leaveWorkspace to import and call
revalidatePath('/workspaces') after the workspace member deletion succeeds, so
the workspace list cache is invalidated before returning. Also make the
deleted.length check null-safe by using optional chaining or an explicit null
check while preserving the existing not-found and owner error handling.
In `@src/features/manage-member-profile/ui/MemberProfileForm.tsx`:
- Around line 134-149: Update the showLeaveConfirm Dialog flow so it cannot
close while isLeaving is true: guard onOpenChange from accepting false and
prevent the cancel button from hiding the modal during the leave request.
Preserve normal closing behavior when isLeaving is false.
In `@src/shared/lib/middleware.ts`:
- Around line 62-72: Update the redirect branches in the middleware, including
the existing unauthenticated redirect and the profile/login redirects, to copy
all cookies from the existing supabaseResponse onto each newly created
NextResponse.redirect response before returning it. Follow the cookie-copying
guidance near the response handling comments and preserve each redirect
destination.
In `@src/shared/lib/use-logout.ts`:
- Around line 4-8: Update handleLogout so the supabase.auth.signOut() call is
wrapped in try...finally, ensuring window.location.href is set to '/login' in
the finally block regardless of network or server errors. Preserve the existing
logout call and redirect behavior.
🪄 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: ec94021f-22ff-47d1-946b-e304da4f23d8
📒 Files selected for processing (9)
src/entities/workspace-member/api/leave-workspace.tssrc/entities/workspace-member/index.tssrc/features/manage-member-profile/ui/MemberProfileForm.tsxsrc/shared/lib/middleware.tssrc/shared/lib/use-logout.tssrc/views/settings/ui/SettingsView.tsxsrc/widgets/workspace-shell/ui/WorkspaceHeader.tsxsrc/widgets/workspace-shell/ui/WorkspaceShell.tsxsrc/widgets/workspace-shell/ui/WorkspaceSidebar.tsx
seongjinss555
left a comment
There was a problem hiding this comment.
리뷰 남겨드렸습니다. 확인해주시고 수정해주세요~ 고생하셨습니다
| const handleLogout = async () => { | ||
| const supabase = createClient(); | ||
| await supabase.auth.signOut(); | ||
| window.location.href = '/login'; |
There was a problem hiding this comment.
로그아웃 시에 '/login'으로 가는 거 보다 '/'으로 가는 게 더 자연스러워 보이는데 어떻게 생각하실까요..?
There was a problem hiding this comment.
기존 사용자가 워크스페이스에서 로그아웃하는 상황에서는 마케팅을 위한 랜딩 페이지보다는 /login으로 보내는 게 더 매끄러울 것 같아 우선은 유지하도록 하겠습니다 혹 이견 있으시면 말씀 주세요! + 추후 사용자 QA에서 체크해보겠습니다
There was a problem hiding this comment.
알겠습니다! 그럼 그대로 진행해주세요
| @@ -0,0 +1,50 @@ | |||
| 'use server'; | |||
There was a problem hiding this comment.
현재 구현은 일반 멤버만 멤버십 행을 하드 삭제하고, 소유자는 삭제 대상에서 제외한 뒤 소유권 이전 안내를 반환하므로 요구사항에 맞는 것으로 보입니다
- leave-workspace: revalidatePath 추가, deleted null 체크 - middleware: 리다이렉트 응답에 세션 쿠키 복사 (3곳) - MemberProfileForm: 탈퇴 처리 중 팝업 닫힘 방지 - use-logout: signOut 실패해도 로그인 페이지로 이동하도록 try/finally 처리
Pull Request
작업 내용
작업 결과
변경 사항
Added
leaveWorkspace서버 액션 (src/entities/workspace-member/api/leave-workspace.ts)useLogout공용 훅 (src/shared/lib/use-logout.ts) — 헤더/사이드바 로그아웃 로직 중복 제거Changed
WorkspaceHeader.tsx: 아바타를 드롭다운 트리거로 변경, 프로필 설정/로그아웃 메뉴 추가WorkspaceSidebar.tsx: 기존에 동작 없던 로그아웃 버튼에 실제 로그아웃 기능 연결Fixed
redirect()가 클라이언트try/catch에 잡히던 Next.js 이슈 —router.push로 대체)role='member'조건을 걸어 원자적으로 처리하도록 개선실행화면
테스트
npm run check— 대상 파일 lint/typecheck/format 통과)리뷰 체크리스트
feature/*->develop, 배포 시develop또는release/*->main)Type/#issue-number/description형식을 따릅니다.console.log, 주석, 임시 코드를 제거했습니다.리뷰 요청사항
leave-workspace.ts의 원자적 DELETE 처리 방식이 적절한지 확인 부탁드려요관련 이슈
Closes #63
Summary by CodeRabbit