feat: 实现邮箱验证码注册/登录功能
- 后端: 新增验证码服务(生成/存储/验证)和邮件发送服务(开发环境控制台输出) - 后端: 新增 POST /auth/send-code 端点,支持注册/登录/重置密码三种用途 - 后端: 注册流程要求邮箱验证码,验证通过后 is_verified=True - 后端: 登录支持邮箱+密码 或 邮箱+验证码 两种方式 - 前端: 注册页增加验证码输入框和获取验证码按钮(60秒倒计时) - 前端: 登录页增加密码登录/验证码登录双Tab切换 - 测试: conftest 添加 bypass_verification fixture,所有 367 测试通过 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
864af19011
commit
d4081345f7
+21
-2
@@ -93,15 +93,26 @@ export interface LoginRequest {
|
||||
email?: string
|
||||
phone?: string
|
||||
password?: string
|
||||
sms_code?: string
|
||||
email_code?: string
|
||||
}
|
||||
|
||||
export interface RegisterRequest {
|
||||
email?: string
|
||||
email: string
|
||||
phone?: string
|
||||
password: string
|
||||
name: string
|
||||
role: UserRole
|
||||
email_code: string
|
||||
}
|
||||
|
||||
export interface SendEmailCodeRequest {
|
||||
email: string
|
||||
purpose: 'register' | 'login' | 'reset_password'
|
||||
}
|
||||
|
||||
export interface SendEmailCodeResponse {
|
||||
message: string
|
||||
expires_in: number
|
||||
}
|
||||
|
||||
export interface LoginResponse {
|
||||
@@ -257,6 +268,14 @@ class ApiClient {
|
||||
|
||||
// ==================== 认证 ====================
|
||||
|
||||
/**
|
||||
* 发送邮箱验证码
|
||||
*/
|
||||
async sendEmailCode(data: SendEmailCodeRequest): Promise<SendEmailCodeResponse> {
|
||||
const response = await this.client.post<SendEmailCodeResponse>('/auth/send-code', data)
|
||||
return response.data
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户注册
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user