Skip to content

feat: 프로필 설정 로그아웃/팀 탈퇴 기능 추가 (#63) - #65

Merged
0011810 merged 3 commits into
developfrom
Feat/#63/profile-edit
Jul 16, 2026
Merged

feat: 프로필 설정 로그아웃/팀 탈퇴 기능 추가 (#63)#65
0011810 merged 3 commits into
developfrom
Feat/#63/profile-edit

Conversation

@0011810

@0011810 0011810 commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Pull Request

작업 내용

  • 워크스페이스 헤더 아바타 드롭다운에 로그아웃 버튼 연결
  • 프로필 설정 화면에 팀 탈퇴 기능 추가
  • 로그아웃 로직을 공용 훅으로 통합

작업 결과

  • 헤더 우측 아바타 클릭 → "프로필 설정" / "로그아웃" 드롭다운 노출
  • 프로필 설정 > 팀 탈퇴 섹션에서 "탈퇴하기" 클릭 시 확인 팝업 → 탈퇴 → 워크스페이스 목록으로 이동
  • owner 계정은 탈퇴 버튼 비활성화

변경 사항

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 확인(SELECT) 후 삭제(DELETE)가 분리되어 있던 걸 DELETE 쿼리 자체에 role='member' 조건을 걸어 원자적으로 처리하도록 개선

실행화면

스크린샷 2026-07-15 오후 5 30 23 스크린샷 2026-07-15 오후 5 30 36

테스트

  • 로컬 실행 확인
  • 주요 시나리오 확인 (로그아웃, 팀 탈퇴 성공/실패, owner 탈퇴 제한)
  • 영향 범위 확인 (npm run check — 대상 파일 lint/typecheck/format 통과)

리뷰 체크리스트

  • PR base branch가 올바릅니다. (feature/* -> develop, 배포 시 develop 또는 release/* -> main)
  • 브랜치명이 Type/#issue-number/description 형식을 따릅니다.
  • 커밋 메시지가 컨벤션을 따릅니다.
  • 불필요한 console.log, 주석, 임시 코드를 제거했습니다.
  • 타입 에러와 린트 에러를 확인했습니다.
  • CodeRabbit 1차 리뷰를 확인했습니다.
  • CodeRabbit 리뷰 반영 후 Discord에 공유했습니다.
  • 최소 1명 이상의 approve 후 merge합니다.

리뷰 요청사항

  • leave-workspace.ts의 원자적 DELETE 처리 방식이 적절한지 확인 부탁드려요

관련 이슈

Closes #63

Summary by CodeRabbit

  • 새로운 기능
    • 프로필 설정에서 워크스페이스 “팀 탈퇴” 기능을 추가하고, 소유자는 소유권 이전 후 탈퇴하도록 안내합니다.
    • 사용자 아바타 메뉴에서 프로필 설정으로 이동 및 로그아웃을 지원하고, 사이드바에서도 로그아웃 기능을 제공합니다.
  • 개선/변경
    • 로그인·회원가입 화면은 프로필 등록 상태에 따라 워크스페이스로 안내하거나 로그인 흐름을 조정합니다.
    • 탈퇴 시 확인 다이얼로그/처리 중 상태 및 실패 시 안내 메시지를 제공합니다.

0011810 added 2 commits July 15, 2026 17:18
- 워크스페이스 헤더/사이드바 로그아웃 버튼 연결 (useLogout 공용 훅)
- 팀 탈퇴 기능 추가 (workspace_members 하드 딜리트, role='member' 조건으로 원자적 처리)
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 64800f32-2fbf-4e85-b263-c850a2f40c01

📥 Commits

Reviewing files that changed from the base of the PR and between ddf5618 and c7a1efe.

📒 Files selected for processing (4)
  • src/entities/workspace-member/api/leave-workspace.ts
  • src/features/manage-member-profile/ui/MemberProfileForm.tsx
  • src/shared/lib/middleware.ts
  • src/shared/lib/use-logout.ts

📝 Walkthrough

Walkthrough

워크스페이스 멤버 탈퇴 서버 액션과 프로필 UI가 추가되었습니다. 헤더와 사이드바에 로그아웃 기능이 연결되었고, 인증 페이지 라우팅이 프로필 상태에 따라 변경되었습니다.

Changes

워크스페이스 프로필 및 멤버 관리

Layer / File(s) Summary
멤버 탈퇴 서버 액션
src/entities/workspace-member/api/leave-workspace.ts, src/entities/workspace-member/index.ts
workspaceId를 검증하고 본인 멤버 레코드를 삭제하며, 소유자와 멤버 정보 부재 상태를 구분해 오류를 반환합니다.
프로필 설정의 팀 탈퇴 UI
src/features/manage-member-profile/ui/MemberProfileForm.tsx, src/views/settings/ui/SettingsView.tsx
소유자 여부를 전달하고, 팀 탈퇴 섹션과 확인 다이얼로그, 로딩·오류 처리 및 성공 후 워크스페이스 목록 이동을 추가했습니다.
헤더 및 사이드바 로그아웃
src/shared/lib/use-logout.ts, src/widgets/workspace-shell/ui/WorkspaceHeader.tsx, src/widgets/workspace-shell/ui/WorkspaceSidebar.tsx, src/widgets/workspace-shell/ui/WorkspaceShell.tsx
로그아웃 훅을 추가하고 헤더 아바타 드롭다운과 사이드바 버튼에서 세션 종료 후 /login으로 이동하도록 연결했습니다.
인증 페이지 라우팅
src/shared/lib/middleware.ts
프로필의 real_name 조회 결과와 현재 인증 경로에 따라 /workspaces 또는 /signup으로 리다이렉트합니다.

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 이동
Loading

Possibly related PRs

Suggested reviewers: jiwoonge

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed 제목이 로그아웃과 팀 탈퇴 기능 추가라는 핵심 변경을 정확히 요약합니다.
Description check ✅ Passed 작업 내용, 결과, 변경 사항, 테스트, 체크리스트, 이슈 링크가 템플릿에 맞게 대부분 채워져 있습니다.
Linked Issues check ✅ Passed 헤더 로그아웃, 공용 훅, 팀 탈퇴 액션, owner 제한, 탈퇴 UI, /workspaces 이동이 이슈 #63 요구사항과 일치합니다.
Out of Scope Changes check ✅ Passed 변경 사항은 로그아웃과 팀 탈퇴 흐름을 지원하는 범위로 보이며, 명백한 무관 변경은 보이지 않습니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch Feat/#63/profile-edit

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.

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

📥 Commits

Reviewing files that changed from the base of the PR and between aa580e1 and ddf5618.

📒 Files selected for processing (9)
  • src/entities/workspace-member/api/leave-workspace.ts
  • src/entities/workspace-member/index.ts
  • src/features/manage-member-profile/ui/MemberProfileForm.tsx
  • src/shared/lib/middleware.ts
  • src/shared/lib/use-logout.ts
  • src/views/settings/ui/SettingsView.tsx
  • src/widgets/workspace-shell/ui/WorkspaceHeader.tsx
  • src/widgets/workspace-shell/ui/WorkspaceShell.tsx
  • src/widgets/workspace-shell/ui/WorkspaceSidebar.tsx

Comment thread src/entities/workspace-member/api/leave-workspace.ts
Comment thread src/features/manage-member-profile/ui/MemberProfileForm.tsx Outdated
Comment thread src/shared/lib/middleware.ts
Comment thread src/shared/lib/use-logout.ts

@seongjinss555 seongjinss555 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

리뷰 남겨드렸습니다. 확인해주시고 수정해주세요~ 고생하셨습니다

Comment thread src/shared/lib/use-logout.ts Outdated
const handleLogout = async () => {
const supabase = createClient();
await supabase.auth.signOut();
window.location.href = '/login';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

로그아웃 시에 '/login'으로 가는 거 보다 '/'으로 가는 게 더 자연스러워 보이는데 어떻게 생각하실까요..?

@0011810 0011810 Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

기존 사용자가 워크스페이스에서 로그아웃하는 상황에서는 마케팅을 위한 랜딩 페이지보다는 /login으로 보내는 게 더 매끄러울 것 같아 우선은 유지하도록 하겠습니다 혹 이견 있으시면 말씀 주세요! + 추후 사용자 QA에서 체크해보겠습니다

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

알겠습니다! 그럼 그대로 진행해주세요

@@ -0,0 +1,50 @@
'use server';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

현재 구현은 일반 멤버만 멤버십 행을 하드 삭제하고, 소유자는 삭제 대상에서 제외한 뒤 소유권 이전 안내를 반환하므로 요구사항에 맞는 것으로 보입니다

Comment thread src/entities/workspace-member/api/leave-workspace.ts
Comment thread src/shared/lib/middleware.ts
- leave-workspace: revalidatePath 추가, deleted null 체크
- middleware: 리다이렉트 응답에 세션 쿠키 복사 (3곳)
- MemberProfileForm: 탈퇴 처리 중 팝업 닫힘 방지
- use-logout: signOut 실패해도 로그인 페이지로 이동하도록 try/finally 처리
@0011810
0011810 merged commit 8bd2313 into develop Jul 16, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: 프로필 설정 로그아웃/팀 탈퇴 기능 추가

2 participants