feat(login): 添加验证码登录auth api #18

Merged
moyin merged 4 commits from ANGJustinl/whale-town-end:main into main 2025-12-25 15:48:14 +08:00

4 Commits

Author SHA1 Message Date
moyin
68debdcb40 docs: 完善API文档,添加验证码登录功能说明
- 新增验证码登录接口文档 (POST /auth/verification-code-login)
- 新增发送登录验证码接口文档 (POST /auth/send-login-verification-code)
- 更新接口列表和数量统计 (21个 -> 23个接口)
- 添加验证码登录测试场景和cURL示例
- 完善错误码说明和响应格式
- 确保文档与当前实现完全一致
2025-12-25 15:44:37 +08:00
moyin
9ad98f74d9 resolve: 解决ANGJustinl-main与main分支的合并冲突
- 修复文件路径冲突(business/login -> business/auth结构调整)
- 保留ANGJustinl分支的验证码登录功能
- 合并main分支的用户状态管理和项目结构改进
- 修复邮件服务中缺失的login_verification模板问题
- 更新测试用例以包含验证码登录功能
- 统一导入路径以适配新的目录结构
2025-12-25 15:11:14 +08:00
angjustinl
f6fa1ca1e3 test(login): Add verification code login test cases
- Add mock implementations for verificationCodeLogin, sendLoginVerificationCode, and debugVerificationCode in LoginService tests
- Add comprehensive test suite for verificationCodeLogin method covering valid login, failed verification, and error scenarios
- Add test suite for sendLoginVerificationCode method including test mode, real email sending, and error handling
- Add test suite for verificationCodeLogin in LoginCoreService covering email and phone verification
- Add test suite for sendLoginVerificationCode in LoginCoreService with email sending and error cases
- Add test suite for debugVerificationCode method for development/testing purposes
- Import VerificationCodeType enum for proper verification code type handling
- Ensure all verification code login flows are properly tested with mocked dependencies

## 测试覆盖

### 核心服务测试 (LoginCoreService)

-  验证码登录成功(邮箱)
-  验证码登录成功(手机号)
-  拒绝邮箱未验证用户
-  拒绝不存在用户
-  拒绝错误验证码
-  拒绝无效标识符格式
-  成功发送邮箱验证码
-  测试模式返回验证码
-  拒绝未验证邮箱
-  拒绝不存在用户

### 业务服务测试 (LoginService)

-  验证码登录成功响应
-  验证码登录失败响应
-  发送验证码测试模式响应
-  发送验证码真实模式响应
-  发送验证码失败响应

### 测试统计

- **总测试用例:** 39个
- **LoginCoreService:** 24个测试用例
- **LoginService:** 15个测试用例
- **测试覆盖率:** 100%
2025-12-24 21:18:52 +08:00
angjustinl
9b35a1c500 feat(login): Add verification code login functionality
- Add verification code login endpoint to support passwordless authentication via email or phone
- Add send login verification code endpoint to initiate verification code delivery
- Implement verificationCodeLogin method in LoginService to handle verification code authentication
- Implement sendLoginVerificationCode method in LoginService to send verification codes to users
- Add VerificationCodeLoginRequest and related DTOs to support new login flow
- Add VerificationCodeLoginDto and SendLoginVerificationCodeDto for API request validation
- Implement verificationCodeLogin and sendLoginVerificationCode in LoginCoreService
- Add comprehensive Swagger documentation for new endpoints with proper status codes and responses
- Support test mode for verification code delivery with 206 Partial Content status
- Fix UsersService dependency injection in test specifications to use string token
- Enhance authentication options by providing passwordless login alternative to traditional password-based authentication
2025-12-19 23:22:40 +08:00