Commit Graph

27 Commits

Author SHA1 Message Date
moyin
2d10131838 refactor:重构Zulip模块按业务功能模块化架构
- 将技术实现服务从business层迁移到core层
- 创建src/core/zulip/核心服务模块,包含API客户端、连接池等技术服务
- 保留src/business/zulip/业务逻辑,专注游戏相关的业务规则
- 通过依赖注入实现业务层与核心层的解耦
- 更新模块导入关系,确保架构分层清晰

重构后的架构符合单一职责原则,提高了代码的可维护性和可测试性
2025-12-31 15:44:36 +08:00
angjustinl
3dd5f23d79 fix(zulip): Fix e2e test errors and pdate author attribution across all Zulip integration files
- Standardize author attribution across 27 files in the Zulip integration module
- Maintain consistent code documentation and authorship tracking
2025-12-25 23:37:26 +08:00
angjustinl
daaf5c3f22 Merge branch 'main' into zulip_dev
* main: (31 commits)
  docs:更新README中的测试说明
  chore:整理API测试脚本
  test:添加验证码冷却时间清除功能测试
  feat:集成验证码冷却时间自动清除机制
  feat:添加验证码冷却时间清除功能
  api:更新登录验证码接口Swagger注解
  docs:更新登录验证码邮件模板修复相关文档
  test:添加登录验证码邮件发送测试
  fix:修复登录验证码邮件模板错误
  feat: 邮箱冲突检测优化 v1.1.1
  docs: 更新API文档,反映HTTP状态码修复
  fix: 修复用户注册冲突错误的HTTP状态码问题
  chore: 升级版本到1.1.0
  feat(docs): 更新OpenAPI文档,添加验证码登录和完整接口定义
  fix(docs): 修正API文档中的错误码和验证码说明
  docs: 完善API文档,添加验证码登录功能说明
  fix:修复注册逻辑和HTTP状态码问题
  fix:修复API状态码和限流配置问题
  chore: 清理旧文件和更新项目配置
  refactor: 更新核心服务和应用配置
  ...
2025-12-25 23:27:24 +08:00
angjustinl
55cfda0532 feat(zulip): 添加全面的 Zulip 集成系统
* **新增 Zulip 模块**:包含完整的集成服务,涵盖客户端池(client pool)、会话管理及事件处理。
* **新增 WebSocket 网关**:用于处理 Zulip 的实时事件监听与双向通信。
* **新增安全服务**:支持 API 密钥加密存储及凭据的安全管理。
* **新增配置管理服务**:支持配置热加载(hot-reload),实现动态配置更新。
* **新增错误处理与监控服务**:提升系统的可靠性与可观测性。
* **新增消息过滤服务**:用于内容校验及速率限制(流控)。
* **新增流初始化与会话清理服务**:优化资源管理与回收。
* **完善测试覆盖**:包含单元测试及端到端(e2e)集成测试。
* **完善详细文档**:包括 API 参考手册、配置指南及集成概述。
* **新增地图配置系统**:实现游戏地点与 Zulip Stream(频道)及 Topic(话题)的逻辑映射。
* **新增环境变量配置**:涵盖 Zulip 服务器地址、身份验证及监控相关设置。
* **更新 App 模块**:注册并启用新的 Zulip 集成模块。
* **更新 Redis 接口**:以支持增强型的会话管理功能。
* **实现 WebSocket 协议支持**:确保与 Zulip 之间的实时双向通信。
2025-12-25 22:22:30 +08:00
moyin
0005dc773c api:更新登录验证码接口Swagger注解
更新发送登录验证码接口的ApiOperation描述,
明确说明邮件使用专门的登录验证码模板,
内容标识为登录验证而非密码重置。
2025-12-25 20:41:00 +08:00
moyin
d683f0d5da feat: 邮箱冲突检测优化 v1.1.1
- 新增邮箱冲突检测:发送验证码前检查邮箱是否已被注册
- 优化用户体验:避免向已注册邮箱发送无用验证码
- 改进错误处理:返回409 Conflict状态码和明确错误信息
- 更新API文档:重新整理文档结构,突出前端开发要点
- 完善测试用例:添加邮箱冲突检测相关测试
- 版本升级:1.1.0  1.1.1

核心修改:
- src/core/login_core/login_core.service.ts: 在sendEmailVerification方法中添加邮箱存在性检查
- src/business/auth/controllers/login.controller.ts: 正确处理409冲突状态码
- docs/api/api-documentation.md: 重新整理为精简实用的前端开发文档
- docs/api/openapi.yaml: 更新版本和接口描述
- test-register-fix.ps1: 添加邮箱冲突检测测试用例
2025-12-25 18:31:36 +08:00
moyin
8a19bb7daa fix: 修复用户注册冲突错误的HTTP状态码问题
问题修复:
- 用户名冲突:400  409 Conflict
- 邮箱冲突:400  409 Conflict
- 手机号冲突:400  409 Conflict

 保持其他错误返回400:
- 验证码错误:400 Bad Request
- 参数格式错误:400 Bad Request

 符合RESTful API规范:
- 409 Conflict:资源冲突
- 400 Bad Request:请求参数错误

 测试验证:
- 邮箱冲突正确返回409
- 用户名冲突正确返回409
- 验证码错误正确返回400
2025-12-25 16:26:55 +08:00
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
moyin
cb25703892 fix:修复API状态码和限流配置问题
- 修复登录控制器HTTP状态码问题,现在根据业务结果返回正确状态码
- 调整注册接口限流配置,从3次/5分钟放宽至10次/5分钟(开发环境)
- 新增清除限流记录的调试接口,便于开发测试
- 更新API文档,反映状态码修复和限流调整
- 添加测试脚本验证修复效果

主要修复:
- 业务失败时返回400/401而非200/201状态码
- 注册、登录、GitHub OAuth等接口现在正确处理错误状态码
- 限流配置更适合开发环境测试需求
2025-12-24 19:41:21 +08:00
moyin
47a738067a feat: 重构业务模块架构
- 新增auth模块处理认证逻辑
- 新增security模块处理安全相关功能
- 新增user-mgmt模块管理用户相关操作
- 新增shared模块存放共享组件
- 重构admin模块,添加DTO和Guards
- 为admin模块添加测试文件结构
2025-12-24 18:04:30 +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
jianuo
43c9cbc863 test:添加管理后台的单元测试 2025-12-19 23:18:57 +08:00
jianuo
a4a3a60db7 feat:添加日志功能 2025-12-19 20:01:45 +08:00
jianuo
dd4fb6edd3 feat:简单添加管理员后台功能 2025-12-19 19:17:47 +08:00
angjustinl
26ea5ac815 feat(sql, auth, email, dto):重构邮箱验证流程,引入基于内存的用户服务,并改进 API 响应处理
* 新增完整的 API 状态码文档,并对测试模式进行特殊处理(`206 Partial Content`)
* 重组 DTO 结构,引入 `app.dto.ts` 与 `error_response.dto.ts`,以实现统一、规范的响应格式
* 重构登录相关 DTO,优化命名与结构,提升可维护性
* 实现基于内存的用户服务(`users_memory.service.ts`),用于开发与测试环境
* 更新邮件服务,增强验证码生成逻辑,并支持测试模式自动识别
* 增强登录控制器与服务层的错误处理能力,统一响应行为
* 优化核心登录服务,强化参数校验并集成邮箱验证流程
* 新增 `@types/express` 依赖,提升 TypeScript 类型支持与开发体验
* 改进 `main.ts`,优化应用初始化流程与配置管理
* 在所有服务中统一错误处理机制,采用标准化的错误响应格式
* 实现测试模式(`206`)与生产环境邮件发送(`200`)之间的无缝切换
2025-12-18 00:17:43 +08:00
moyin
34a9e727b4 feat:添加验证码调试功能
- 在验证码服务中添加debugCodeInfo方法
- 在业务层添加debugVerificationCode调试接口
- 新增/auth/debug-verification-code调试端点
- 支持查看验证码详细状态信息(TTL、尝试次数等)
- 便于开发和生产环境问题排查
2025-12-17 21:23:22 +08:00
moyin
c2ddb67b3e service:更新登录业务服务支持邮箱验证
- 添加发送邮箱验证码服务方法
- 添加验证邮箱验证码服务方法
- 添加重新发送邮箱验证码服务方法
- 集成验证码服务和邮件服务
- 更新相关的单元测试
2025-12-17 20:22:10 +08:00
moyin
5b07535002 api:更新注册接口支持邮箱验证码
- 注册接口传递邮箱验证码参数到服务层
- 更新 API 文档描述,说明验证码使用流程
- 添加发送邮箱验证码接口
- 添加验证邮箱验证码接口
- 添加重新发送邮箱验证码接口
2025-12-17 20:07:11 +08:00
moyin
94ba3077aa dto:为注册接口添加邮箱验证码参数
- 在 RegisterDto 中添加 email_verification_code 可选字段
- 更新 RegisterRequest 接口定义
- 在注册核心服务中添加验证码验证逻辑
- 提供邮箱时必须提供有效的验证码进行验证
2025-12-17 20:06:56 +08:00
moyin
d28100e103 api:为登录控制器添加完整的Swagger文档
- 添加ApiTags、ApiOperation等装饰器
- 配置详细的请求和响应文档
- 提供HTTP状态码和错误处理说明
2025-12-17 15:16:10 +08:00
moyin
0692aaadcc dto:创建API响应数据传输对象
- 创建LoginResponseDto、RegisterResponseDto等响应DTO
- 定义标准化的API响应格式
- 添加完整的Swagger类型定义
2025-12-17 15:15:53 +08:00
moyin
76f5fa99a6 dto:为登录相关DTO添加Swagger文档注解
- 为LoginDto、RegisterDto等添加ApiProperty装饰器
- 完善字段描述、示例值和验证规则说明
- 提供详细的API参数文档
2025-12-17 15:15:35 +08:00
moyin
e350d117d3 feat:实现用户认证系统
- 添加用户登录、注册、密码重置功能
- 支持用户名/邮箱/手机号多种登录方式
- 集成GitHub OAuth第三方登录
- 实现bcrypt密码加密存储
- 添加基于角色的权限控制
- 包含完整的数据验证和错误处理
2025-12-17 14:39:45 +08:00
moyin
8591f23505 chore:清理空的gitkeep文件和临时文件
- 删除不再需要的.gitkeep占位文件
- 清理开发过程中的临时测试文件
2025-12-17 11:03:40 +08:00
moyin
7ebc75e678 chore:优化项目目录结构
- 清理不必要的 .gitkeep 占位文件
- 保留必要目录的 .gitkeep 文件
- 统一项目文件组织结构
2025-12-13 16:20:13 +08:00