Files
gitlab-instance-0a899031_di…/docs/AUTH_PAYMENT_VIP_CHECK_REPORT.md
2026-03-12 05:40:18 -05:00

56 lines
2.2 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 登录/支付/VIP 权限检查报告
检查范围digital、cnomadcna、nomadvip、payjsapi
## 一、登录流程
| 项目 | /api/auth/me | /api/auth/sync-session | /api/auth/logout | credentials |
|------|--------------|------------------------|------------------|-------------|
| digital | ✅ 读 pb_sessionrefresh 回写 | ✅ 设置 Cookie | ✅ 清除 Cookie | ✅ include |
| cnomadcna | ✅ | ✅ | ✅ | ✅ AuthModal/JoinModal |
| nomadvip | ✅ | ✅ | ✅ | ✅ AuthForm |
**Cookie domain**
- digital已用 `getAuthCookieDomain(request)`localhost 不设 domain
- cnomadcna已改为 `getAuthCookieDomain`localhost 兼容
- nomadvip已改为 `getAuthCookieDomain`localhost 兼容
## 二、支付流程
| 项目 | 前端入口 | Next.js API | payjsapi 路径 | site_id |
|------|----------|-------------|---------------|---------|
| digital | join 页 / Roadmap | /api/pay | /digital/payh5 | digital |
| cnomadcna | HeroSection JoinModal | /api/pay | /cnomadcna/payh5 | meetup |
| nomadvip | 支付页 | 直接调 payjsapi | /nomadvip/payh5 | vip |
**payjsapi 回调:**
- digital/cnomadcna`_digital_base`xorpay_notify / zpay_notify → `handle_payment_success` → site_vip
- nomadvipxorpay_notify / zpay_notify → `handle_payment_success` → site_vip
- meetup 类型effective_site_id 固定为 "meetup"
- vip 类型effective_site_id 为 "vip"
## 三、VIP 权限
| 项目 | SITE_ID | VIP 校验逻辑 |
|------|---------|--------------|
| digital | digital | site_id=digital 或 site_id=vip |
| cnomadcna | meetup | site_id=meetup |
| nomadvip | vip | site_id=vip |
**site_vip 表:** user_id + site_id + order_id + expires_at
## 四、环境变量
| 变量 | 说明 |
|------|------|
| AUTH_COOKIE_DOMAIN | 生产环境根域,如 .hackrobot.cn |
| POCKETBASE_EMAIL / POCKETBASE_PASSWORD | VIP 查询用 admin |
| PAYMENT_API_URL | payjsapi 地址,如 https://api.hackrobot.cn |
| NEXT_PUBLIC_POCKETBASE_URL | PocketBase 地址 |
| NEXT_PUBLIC_SITE_ID | digital / meetup / vip |
## 五、本次修复
1. **cnomadcna**auth/me、sync-session、logout 改用 `getAuthCookieDomain`,支持 localhost
2. **nomadvip**:同上,新增 `app/lib/auth-cookie-domain.ts`