Commit Graph

104 Commits

Author SHA1 Message Date
moyin
d59e9531e2 fix(docs): 修正API文档中的错误码和验证码说明
- 修正验证码登录错误码:VERIFICATION_CODE_INVALID -> VERIFICATION_CODE_LOGIN_FAILED
- 修正发送登录验证码错误码:USER_NOT_FOUND -> SEND_LOGIN_CODE_FAILED
- 添加验证码登录相关错误码到错误码表格
- 完善验证码使用说明和注意事项
- 确保文档与实际API响应完全一致
2025-12-25 16:04:34 +08:00
28a39935b7 Merge pull request 'feat(login): 添加验证码登录auth api' (#18) from ANGJustinl/whale-town-end:main into main
Reviewed-on: datawhale/whale-town-end#18
2025-12-25 15:48:13 +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
578cba39a7 Merge pull request 'fix:修复注册逻辑和HTTP状态码问题' (#22) from fix/registration-logic-and-status-codes into main
Reviewed-on: datawhale/whale-town-end#22
2025-12-24 20:41:18 +08:00
moyin
404ef5d3e0 fix:修复注册逻辑和HTTP状态码问题
核心修复:
- 调整注册流程检查顺序,先验证用户存在性再验证验证码
- 修复HTTP状态码问题,业务失败时返回正确的错误状态码
- 优化错误处理逻辑,提供更准确的错误信息

主要变更:
- 登录核心服务:重构注册方法,优化检查顺序避免验证码无效消费
- 用户服务:分离用户创建和重复检查逻辑,提高代码复用性
- 登录控制器:修复HTTP状态码处理,根据业务结果返回正确状态码
- API文档:更新注册接口说明和错误响应示例
- 测试脚本:优化测试逻辑和注释说明

修复效果:
- 用户已存在时立即返回正确错误信息,不消费验证码
- API响应状态码准确反映业务执行结果
- 错误信息更加用户友好和准确
- 验证码使用更加合理和高效

测试验证:
- 所有核心功能测试通过
- 注册逻辑修复验证成功
- HTTP状态码修复验证成功
- 限流功能正常工作
2025-12-24 20:39:23 +08:00
e537e782a9 Merge pull request 'fix:修复API状态码和限流配置问题' (#21) from fix/api-status-codes-and-throttle into main
Reviewed-on: datawhale/whale-town-end#21
2025-12-24 19:41: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
64230db651 Merge pull request 'feature/refactor-project-structure' (#20) from feature/refactor-project-structure into main
Reviewed-on: datawhale/whale-town-end#20
2025-12-24 18:07:32 +08:00
moyin
612755de63 chore: 清理旧文件和更新项目配置
- 删除旧的DTO文件(已迁移到对应业务模块)
- 删除旧的测试目录结构
- 删除过时的API目录
- 更新package.json配置
- 移除不再使用的文件
2025-12-24 18:05:07 +08:00
moyin
e6d8c28806 refactor: 更新核心服务和应用配置
- 更新用户实体和DTO结构
- 重构用户服务逻辑
- 更新登录核心服务
- 调整应用模块配置以适配新的业务模块结构
- 更新应用控制器和服务
2025-12-24 18:04:53 +08:00
moyin
47a738067a feat: 重构业务模块架构
- 新增auth模块处理认证逻辑
- 新增security模块处理安全相关功能
- 新增user-mgmt模块管理用户相关操作
- 新增shared模块存放共享组件
- 重构admin模块,添加DTO和Guards
- 为admin模块添加测试文件结构
2025-12-24 18:04:30 +08:00
moyin
85d488a508 docs: 重构文档结构和组织
- 重新组织docs目录结构,按功能模块分类
- 新增deployment和development目录
- 更新API文档结构
- 添加客户端README文档
- 移除过时的文档文件
2025-12-24 18:04:14 +08:00
moyin
032c97a1fc docs: 全面更新API接口文档
- 重构文档结构,按功能模块分类
- 新增应用状态接口 (GET /)
- 完善用户认证接口,新增4个邮箱验证相关接口
- 新增管理员后台接口,包含用户管理和日志管理
- 更新错误代码说明和数据验证规则
- 完善使用示例和注意事项
- 更新版本日志至v1.0.0

涵盖后端所有API接口,提供完整的开发参考文档
2025-12-23 19:51:34 +08:00
0313b78852 Merge pull request 'docs:更新README、贡献者文档和部署指南' (#19) from docs/update-admin-documentation into main
Reviewed-on: datawhale/whale-town-end#19
2025-12-22 15:15:48 +08:00
moyin
d80d2c5cb8 docs:更新README、贡献者文档和部署指南
- 更新README.md:添加管理员后台系统介绍,更新测试统计为154个用例
- 更新CONTRIBUTORS.md:补充jianuo的管理员后台开发贡献,更新项目里程碑
- 更新DEPLOYMENT.md:完善前后端分离部署方案,添加管理员后台配置说明
- 反映最新管理员后台功能的部署要求和配置变更
2025-12-22 15:13:04 +08:00
2fb46967c7 Merge pull request 'feat:添加管理员后台功能' (#17) from jianuo/whale-town-end:feat_2 into main
Reviewed-on: datawhale/whale-town-end#17
Reviewed-by: moyin <2443444649@qq.com>
2025-12-22 14:56:13 +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
8166c95af4 feat: update TypeScript configuration to use Node16 module and resolution 2025-12-19 19:34:18 +08:00
jianuo
ec2e346ded docs:更新技术栈 2025-12-19 19:24:31 +08:00
jianuo
dd4fb6edd3 feat:简单添加管理员后台功能 2025-12-19 19:17:47 +08:00
17c16588aa merge upstream 2025-12-19 16:31:15 +08:00
8fc2b53c00 revert 11387f7046
revert 修复文档错误
2025-12-19 16:31:08 +08:00
4e2f46223e Merge pull request '更新 README.md' (#16) from moyin-patch-1 into main
Reviewed-on: datawhale/whale-town-end#16
2025-12-18 15:24:41 +08:00
f079a80b66 更新 README.md 2025-12-18 15:24:33 +08:00
bc16187fe0 Merge pull request 'fix:修复LoginCoreService依赖注入问题,支持双模式用户服务' (#15) from docs/update-readme-and-contributors into main
Reviewed-on: datawhale/whale-town-end#15
2025-12-18 15:10:28 +08:00
moyin
b99b77e08b fix:修复LoginCoreService依赖注入问题,支持双模式用户服务
- 添加@Inject('UsersService')装饰器到LoginCoreService构造函数
- 支持根据配置动态切换UsersService和UsersMemoryService
- 确保开发测试模式和生产环境的无缝切换
- 修复之前服务启动时的依赖注入错误
2025-12-18 15:06:57 +08:00
7afd9a52fa Merge pull request 'docs:重构README和贡献者文档,完善项目架构说明和测试指南' (#14) from docs/update-readme-and-contributors into main
Reviewed-on: datawhale/whale-town-end#14
2025-12-18 15:04:21 +08:00
moyin
7924cfb201 docs:重构README和贡献者文档,完善项目架构说明和测试指南
- 重构README结构,按新开发者学习流程组织内容
- 更新项目架构图和技术栈说明,基于实际代码结构
- 创建CONTRIBUTORS.md,记录所有贡献者信息和统计
- 添加TESTING.md测试指南,支持无依赖快速测试
- 创建docs/ARCHITECTURE.md详细架构设计文档
- 优化.env.example配置,支持测试和生产环境切换
- 添加跨平台测试脚本(test-api.ps1/test-api.sh)
- 删除冗余测试文件,统一测试入口
- 更新所有链接为正确的Gitea仓库地址
- 添加MIT开源协议文件
2025-12-18 15:03:09 +08:00
d322db242d Merge pull request '[REVIEW REQUIRED]feat(sql, auth, email, dto):重构邮箱验证流程,引入基于内存的用户服务,并改进 API 响应处理' (#12) from ANGJustinl/whale-town-end:main into main
Reviewed-on: datawhale/whale-town-end#12
2025-12-18 14:21:24 +08:00
moyin
d4a7b36129 Merge branch 'main' of https://gitea.xinghangee.icu/datawhale/whale-town-end into ANGJustinl-main 2025-12-18 14:12:45 +08:00
243ca05028 Merge pull request 'fix: 修复测试用例中的问题' (#13) from fix/test-issues into main
Reviewed-on: datawhale/whale-town-end#13
2025-12-18 13:36:13 +08:00
moyin
3cfebbc4c4 fix: 修复测试用例中的问题
- 修复邮件服务测试中未使用的变量警告
- 修复验证服务测试中的TTL和返回值期望问题
- 确保所有113个测试用例通过

详细修改:
- email.service.spec.ts: 移除4个未使用的testService变量
- verification.service.spec.ts:
  * 添加TTL mock值避免异常分支
  * 更新getCodeStats期望值包含code和createdAt字段
  * 修正TTL期望值从-1改为-2(Redis标准)

测试结果: 6个测试套件,113个测试用例全部通过
2025-12-18 13:33:40 +08:00
angjustinl
6dece752ef test(email, verification, login): 更新测试中的断言内容, 修复测试error.
- Replace boolean assertions with structured result object checks in email service tests
- Update email service tests to verify success flag and isTestMode property
- Add error message assertions for failed email sending scenarios
- Change logger spy from 'log' to 'warn' for test mode email output
- Update test message to clarify emails are not actually sent in test mode
- Add code and createdAt properties to verification code stats mock data
- Fix TTL mock value from -1 to -2 to correctly represent non-existent keys
- Replace Inject decorator with direct UsersService type injection in LoginCoreService
- Ensure verification service tests properly mock TTL values during code verification
- Improve test coverage by validating complete response structures instead of simple booleans
2025-12-18 13:29:55 +08:00
76d794571c Merge pull request 'fix: 修复docker部署问题' (#11) from jianuo/whale-town-end:fix into main
Reviewed-on: datawhale/whale-town-end#11
Reviewed-by: moyin <2443444649@qq.com>
2025-12-18 11:20:53 +08:00
928c3700aa Merge pull request 'docs: 修复文档错误' (#10) from jianuo/whale-town-end:docs into main
Reviewed-on: datawhale/whale-town-end#10
2025-12-18 11:19:29 +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
jianuo
5161d614d0 fix: 修复docker部署问题 2025-12-18 00:07:36 +08:00
jianuo
136ba4286c docs: 修复文档错误 2025-12-17 23:19:01 +08:00
jianuo
f7ff0c25f9 docs: 修复文档错误 2025-12-17 23:16:21 +08:00
jianuo
11387f7046 修复文档错误 2025-12-17 22:54:51 +08:00
2a3698b26a Merge pull request 'fix: 修复验证码验证时TTL重置导致过期的关键问题' (#7) from fix/verification-code-ttl-reset into main
Reviewed-on: datawhale/whale-town-end#7
2025-12-17 21:24:24 +08:00
moyin
c8e60c6059 test:添加验证码问题调试脚本
- 创建PowerShell调试脚本用于本地测试
- 包含完整的验证码测试流程
- 支持错误验证和正确验证的对比测试
- 自动显示TTL和尝试次数变化
- 便于快速定位验证码相关问题
2025-12-17 21:23:27 +08:00
moyin
34a9e727b4 feat:添加验证码调试功能
- 在验证码服务中添加debugCodeInfo方法
- 在业务层添加debugVerificationCode调试接口
- 新增/auth/debug-verification-code调试端点
- 支持查看验证码详细状态信息(TTL、尝试次数等)
- 便于开发和生产环境问题排查
2025-12-17 21:23:22 +08:00
moyin
de3b108503 fix:修复验证码验证时TTL被重置的问题
- 修复验证失败时TTL被重置为5分钟的bug
- 保持原有的过期时间,不重置验证码有效期
- 增加详细的TTL变化日志记录
- 改进错误处理和边界情况处理
- 解决用户验证一次错误后验证码立即过期的问题
2025-12-17 21:23:16 +08:00
81dfbd0643 Merge pull request 'feature/email-verification-system' (#6) from feature/email-verification-system into main
Reviewed-on: datawhale/whale-town-end#6
2025-12-17 20:27:20 +08:00
moyin
66f268cf17 chore:移除重复的测试脚本文件
- 删除重复的注册验证测试脚本
- 保持测试文件的整洁性
2025-12-17 20:23:51 +08:00