参考 rwadurian 项目的成熟实现,在 Genex auth-service 上全面增强短信验证体系。
## 新增功能
### Domain 层
- Phone Value Object: E.164 标准化、中国大陆格式自动补+86、掩码显示(138****8000)
- SmsCode Value Object: crypto 安全随机6位生成、格式验证
- SmsVerification Entity: 验证码记录持久化,支持4种类型(REGISTER/LOGIN/RESET_PASSWORD/CHANGE_PHONE)
- SmsLog Entity: SMS发送日志审计追踪(provider/status/error)
- User Entity 增强: loginFailCount + lockedUntil 字段,指数退避锁定策略(1→2→4→8...→1440分钟)
- 5个新 Domain Events: SmsCodeSent, SmsCodeVerified, AccountLocked, PhoneChanged, PasswordReset
### Infrastructure 层
- 3个 SQL 迁移: users表锁定字段(041), sms_verifications表(042), sms_logs表(043)
- SmsVerification/SmsLog TypeORM Repository 实现
- SMS Provider 抽象层: ISmsProvider 接口 + ConsoleSmsProvider(开发) + AliyunSmsProvider(生产)
- Redis SmsCodeService 增强: 类型前缀 auth:sms:{type}:{phone},保留向后兼容
### Application 层
- 独立 SmsService: 发送验证码(日限额10条+业务规则校验) + 验证验证码(尝试限制5次)
- AuthService 重构: 注册需SMS验证、密码登录带锁定检查、+resetPassword/changePhone
### Interface 层
- 新端点: POST /auth/sms/send, POST /auth/reset-password, POST /auth/change-phone
- DTO 更新: RegisterDto 增加 smsCode 必填, SendSmsCodeDto 增加 type 枚举
- 全部端点 Swagger 文档
### 配置
- .env.example: SMS_ENABLED, ALIYUN_SMS_*, SMS_DAILY_LIMIT, LOGIN_MAX_FAIL_ATTEMPTS
- auth.module: SMS_PROVIDER 按 SMS_ENABLED 环境变量自动切换
## API 端点一览
- POST /api/v1/auth/sms/send — 发送验证码(4种类型)
- POST /api/v1/auth/register — 手机注册(phone+smsCode+password)
- POST /api/v1/auth/login — 密码登录(带锁定检查)
- POST /api/v1/auth/login-phone — 短信验证码登录
- POST /api/v1/auth/reset-password — 重置密码
- POST /api/v1/auth/change-phone — 换绑手机(需登录)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
||
|---|---|---|
| .claude | ||
| backend | ||
| blockchain | ||
| docs | ||
| frontend | ||
| logo | ||
| .gitignore | ||
| README.md | ||
README.md
Global Coupon Exchange
Website: gogenex.com
Brand Naming Strategy
This project adopts a regional branding strategy, using different brand names for different markets while maintaining brand family consistency.
Brand Structure
| Market | Brand | Abbr | Description |
|---|---|---|---|
| Western (US/Europe) | Genex | GNX | Derived from Generation + Exchange, familiar Western naming style |
| Asian (including China) | Gensen / 券信 | GS | "Gensen" from Cantonese pronunciation of Chinese characters "券信" |
Unified Domain
- gogenex.com - Single global domain for all markets
- Subdomains or paths for regional content (e.g., gogenex.com/cn, gogenex.com/asia)
Naming Logic
Genex (Western Markets)
- Gen = Generation / Generic / Genesis
- ex = Exchange
- Natural pronunciation, similar to well-known Western brands like FedEx, Amex
- Professional, modern, and trustworthy fintech image
Gensen / 券信 (Asian Markets)
- 券 (Quan) = Coupon / Voucher
- 信 (Xin) = Trust / Credit
- Gensen = Romanization of Cantonese pronunciation "gyun seon"
- Use Chinese characters "券信" in Mainland China
- Use romanized "Gensen" in other Asian regions
- Two characters conveying core values: coupon trading + trust guarantee
Brand Consistency
Genex ←── "Gen-" prefix ──→ Gensen
↑ ↑
└─────── Same brand family ────┘
↓
券信 (Chinese localization)
- Genex and Gensen share the "Gen-" prefix, establishing brand family recognition
- Gensen directly transliterates to 券信, providing seamless connection
- Global users can recognize these as regional versions of the same platform
Usage Scenarios
| Scenario | Western Markets | Asian Markets (non-China) | China Market |
|---|---|---|---|
| Company Name | GoGenex Inc. | Gensen Asia Ltd. | 券信科技有限公司 |
| App Name | Genex | Gensen | 券信 |
| Domain | gogenex.com | gogenex.com/asia | gogenex.com/cn |
| Social Media | @gogenex | @gensen_official | @券信official |
Note on Company Structure:
- Inc. (Corporation) for Western markets: Better for VC funding, stock issuance, and potential IPO
- Ltd. (Limited) for Asian markets: Common structure in Asia-Pacific region
- Social media handles use variations to avoid conflicts with existing accounts
Legal & Operations
Due to varying financial regulations across countries, each regional brand will:
- Operate as an independent legal entity
- Comply with local regulatory requirements
- Share core technology platform and philosophy
- Establish brand association through parent company
Project Overview
Global Coupon Exchange (GCX) is a coupon asset trading platform designed to provide users with secure and convenient trading services for digital assets such as coupons, gift cards, and vouchers.
Core Features
- Coupon asset listing and trading
- Secure transaction matching mechanism
- Multi-currency settlement support
- User credit system
Tech Stack
TBD
Documentation
For detailed development documentation, please refer to the docs directory.
License
TBD