Skip to content

feat: Supabase Auth + Discord OAuth 인증 전환#2

Merged
bbbang105 merged 2 commits intodevfrom
feat/supabase-auth
Feb 23, 2026
Merged

feat: Supabase Auth + Discord OAuth 인증 전환#2
bbbang105 merged 2 commits intodevfrom
feat/supabase-auth

Conversation

@bbbang105
Copy link
Copy Markdown
Owner

@bbbang105 bbbang105 commented Feb 23, 2026

Summary

  • 커스텀 JWT 인증(bcrypt + jsonwebtoken + jose + Resend 이메일)을 Supabase Auth + Discord OAuth로 전환
  • Supabase SSR 클라이언트 헬퍼 추가 (client, server, middleware)
  • 모든 API 라우트 및 미들웨어를 Supabase Auth 기반으로 리팩토링
  • 불필요한 인증 관련 파일/라우트 삭제 (-2139줄, +452줄)

Changes

  • 신규: Supabase 클라이언트 헬퍼 (lib/supabase/), OAuth 콜백 (/auth/callback)
  • 수정: 미들웨어, 로그인 페이지, API 라우트 (me, logout, profile, admin), 레이아웃
  • 삭제: auth.ts, email.ts, register/verify-email 페이지, login/register API
  • 보안: 오픈 리다이렉트 방지, profileImageUrl 프로토콜 검증, interests 배열 검증
  • DB: users/sessions 테이블 제거, Transaction pooler 지원 (prepare: false)

Code Review Fix (4de782f)

  • [Critical] admin API(settings, curation, curation/[id])에 withAdminAuth 래퍼 적용 (인증 패턴 통일)
  • [High] members/[id] URL 파싱 시 쿼리파라미터 포함 버그 수정 (new URL().pathname 사용)
  • [High] middleware.ts 관리자 ID 파싱 로직 중복 제거 → isAdminDiscordId() 재사용
  • [Medium] env.ts에서 미사용 authEnvSchema(JWT), emailEnvSchema(Resend) 제거

Test plan

  • Discord OAuth 로그인/로그아웃 동작 확인
  • 미들웨어 라우트 보호 동작 확인 (protected/admin/auth)
  • API 라우트 Supabase Auth 인증 동작 확인
  • 관리자 권한 체크 동작 확인
  • 빌드 성공 확인 (pnpm typecheck && pnpm build)
  • 코드 리뷰 반영 후 타입 체크 통과 확인

🤖 Generated with Claude Code

커스텀 JWT(bcrypt + jsonwebtoken + jose) 인증을 Supabase Auth + Discord OAuth로 교체.

- Supabase SSR 클라이언트 헬퍼 추가 (client, server, middleware)
- OAuth 콜백 라우트 추가 (/auth/callback)
- 로그인 페이지를 Discord OAuth 버튼으로 교체
- 모든 API 라우트를 Supabase Auth 기반으로 리팩토링
- 미들웨어를 Supabase 세션 검증으로 교체
- admin 라우트에 Discord ID 기반 권한 체크 추가
- DB 스키마에서 users/sessions 테이블 제거
- Transaction pooler 지원 (prepare: false)
- 오픈 리다이렉트, profileImageUrl 검증 등 보안 강화
- 불필요한 파일 삭제 (auth.ts, email.ts, register, verify-email 등)

Co-Authored-By: Claude <noreply@anthropic.com>
@bbbang105 bbbang105 added the 🚀 feat 새로운 기능 추가 / 일부 코드 추가 / 일부 코드 수정 (리팩토링과 구분) / 디자인 요소 수정 label Feb 23, 2026
- admin API(settings, curation, curation/[id])에 withAdminAuth 래퍼 적용
- members/[id] URL 파싱 시 쿼리파라미터 버그 수정 (new URL().pathname 사용)
- middleware.ts 관리자 ID 파싱 로직 중복 제거 → isAdminDiscordId() 재사용
- env.ts에서 미사용 authEnvSchema(JWT), emailEnvSchema(Resend) 제거
- CLAUDE.md 최신화

Co-Authored-By: Claude <noreply@anthropic.com>
@bbbang105 bbbang105 added the 🚨 fix 버그 수정 / 에러 해결 label Feb 23, 2026
@bbbang105 bbbang105 merged commit f423621 into dev Feb 23, 2026
5 checks passed
@bbbang105 bbbang105 deleted the feat/supabase-auth branch February 23, 2026 13:48
choihooo added a commit that referenced this pull request Mar 10, 2026
MessageContent Intent (100+ 서버 요구사항) 없이 동작하도록
텍스트 파싱 방식에서 Discord 버튼/인터랙션 방식으로 변경

변경 사항:
- dm-handler.ts: MessageCreate → InteractionCreate 이벤트 핸들러 변경
- sendFineNotification/sendFineReminder: "납부 완료" 버튼 추가
- handleButtonInteraction: 버튼 클릭 시 벌금 상태 PAID로 변경
- bot.ts: 주석 업데이트 (Intent 활성화 불가능 명시)
- fine.service.ts: isPaymentConfirmation, PaymentConfirmationWords @deprecated

P0 #2 MessageContent Intent 비활성화 문제 해결:
- 봇이 1개 서버에만 있어 Message Content Intent 활성화 불가
- 버튼/컴포넌트 기반으로 변경하여 Intent 없이 동작

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
choihooo added a commit that referenced this pull request Mar 10, 2026
* feat: 벌금 납부 확인을 버튼 기반으로 변경

MessageContent Intent (100+ 서버 요구사항) 없이 동작하도록
텍스트 파싱 방식에서 Discord 버튼/인터랙션 방식으로 변경

변경 사항:
- dm-handler.ts: MessageCreate → InteractionCreate 이벤트 핸들러 변경
- sendFineNotification/sendFineReminder: "납부 완료" 버튼 추가
- handleButtonInteraction: 버튼 클릭 시 벌금 상태 PAID로 변경
- bot.ts: 주석 업데이트 (Intent 활성화 불가능 명시)
- fine.service.ts: isPaymentConfirmation, PaymentConfirmationWords @deprecated

P0 #2 MessageContent Intent 비활성화 문제 해결:
- 봇이 1개 서버에만 있어 Message Content Intent 활성화 불가
- 버튼/컴포넌트 기반으로 변경하여 Intent 없이 동작

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

* refactor: ChannelType.DM enum 사용으로 매직 넘버 제거

* feat: 인메모리 pendingConfirmations를 DB 영속화로 변경

P0 #9 문제 해결:
- 인메모리 Map → DB pendingConfirmation 컬럼으로 변경
- 봇 재시작 시 대기 중인 확인 내역 소실 문제 해결

변경 사항:
- schema.ts: fines 테이블에 pendingConfirmation 컬럼 추가
- dm-handler.ts: addPendingConfirmation, removePendingConfirmation을 DB로 변경
- isPendingConfirmation: DB 조회로 변경
- 불필요한 Map 관리 함수 제거

DB 마이그레이션:
- ALTER TABLE fines ADD COLUMN pending_confirmation boolean DEFAULT true
- CREATE INDEX idx_fines_pending_confirmation

테스트 완료:
- ✅ DB에 벌금 생성
- ✅ DM 버튼 발송
- ✅ 버튼 클릭 시 DB에서 pending_confirmation false로 변경
- ✅ 벌금 상태 PAID로 업데이트

장점:
- 봇 재시작 후에도 대기 중인 벌금 확인 유지
- DB 조회로 실시간 동시성 문제 해결
- 인메모리 상태 관리 불필요

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

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🚀 feat 새로운 기능 추가 / 일부 코드 추가 / 일부 코드 수정 (리팩토링과 구분) / 디자인 요소 수정 🚨 fix 버그 수정 / 에러 해결

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant