refactor(admin): CRM을 apps/admin 독립 프로젝트로 분리

- apps/web에서 admin 라우트/가드/sidebar 링크 제거
- apps/admin: 독립 Next.js 앱 (포트 3001)
  - 자체 login/unauthorized/auth callback
  - admin-sidebar: Overview/Users/Subscriptions/Usage
  - requireAdmin() 가드: profile.role='admin' 체크
- monorepo workspace에 apps/admin 등록
This commit is contained in:
윤찬 2026-04-12 20:36:24 +09:00
parent daed9f90d5
commit 46673ee941
23 changed files with 536 additions and 343 deletions

View file

@ -1,32 +0,0 @@
// apps/web/src/lib/admin-guard.ts
// RSC용 admin 가드 — profile.role='admin' 체크, 실패 시 redirect
import { redirect } from 'next/navigation'
import { getSupabaseServerClient } from './supabase-server'
interface AdminProfile {
id: string
name: string | null
role: string
}
export async function requireAdmin(): Promise<AdminProfile> {
const supabase = await getSupabaseServerClient()
const { data: { user } } = await supabase.auth.getUser()
if (!user) {
redirect('/login')
}
const { data: profile } = await supabase
.from('profiles')
.select('id, name, role')
.eq('id', user.id)
.maybeSingle()
if (!profile || (profile as { role: string }).role !== 'admin') {
redirect('/dashboard')
}
return profile as AdminProfile
}