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:
Your Name
2026-02-09 18:49:47 +08:00
co-authored by Claude Opus 4.6
parent 864af19011
commit d4081345f7
18 changed files with 592 additions and 89 deletions
+4 -1
View File
@@ -94,7 +94,10 @@ export function AuthProvider({ children }: { children: ReactNode }) {
if (!mockUser) {
return { success: false, error: '用户不存在' }
}
if (mockUser.password !== credentials.password) {
// 验证码登录或密码登录
if (credentials.email_code) {
// 验证码登录 mock: 任何验证码都通过
} else if (mockUser.password !== credentials.password) {
return { success: false, error: '密码错误' }
}
const { password: _, ...userWithoutPassword } = mockUser