Commit Graph

24 Commits

Author SHA1 Message Date
moyin
bb796a2469 refactor:项目架构重构和命名规范化
- 统一文件命名为snake_case格式(kebab-case  snake_case)
- 重构zulip模块为zulip_core,明确Core层职责
- 重构user-mgmt模块为user_mgmt,统一命名规范
- 调整模块依赖关系,优化架构分层
- 删除过时的文件和目录结构
- 更新相关文档和配置文件

本次重构涉及大量文件重命名和模块重组,
旨在建立更清晰的项目架构和统一的命名规范。
2026-01-08 00:14:14 +08:00
moyin
0192934c66 test:添加验证码冷却时间清除功能测试
为新增的验证码冷却时间清除功能添加全面的测试用例:

验证服务测试:
- 测试成功清除冷却时间
- 测试清除不存在的冷却时间
- 测试Redis操作错误处理
- 测试不同类型和标识符的冷却时间清除

登录核心服务测试:
- 测试注册成功后自动清除冷却时间
- 测试密码重置成功后自动清除冷却时间
- 测试验证码登录成功后自动清除冷却时间
- 测试冷却时间清除失败的优雅处理
2025-12-25 20:49:16 +08:00
moyin
a78df48101 feat:添加验证码冷却时间清除功能
新增 clearCooldown 方法,用于在用户成功完成操作后
清除验证码冷却时间,提升用户体验:
- 注册成功后清除邮箱验证码冷却时间
- 密码重置成功后清除重置验证码冷却时间
- 验证码登录成功后清除登录验证码冷却时间
2025-12-25 20:48:15 +08:00
moyin
841a58886e test:添加登录验证码邮件发送测试
为修复的登录验证码邮件模板功能添加专门的测试用例:
- 测试登录验证码邮件发送功能
- 验证邮件模板内容包含正确的登录验证码信息
- 确保邮件主题和内容符合预期
2025-12-25 20:40:27 +08:00
moyin
91565f716d fix:修复登录验证码邮件模板错误
登录验证码发送时错误地使用了密码重置邮件模板,
导致用户收到的邮件内容显示为'密码重置'而不是'登录验证码'。

修改 EmailService.sendVerificationCode 方法,
当 purpose 为 'login_verification' 时使用正确的
getLoginVerificationTemplate 方法而不是 getPasswordResetTemplate。
2025-12-25 20:40:08 +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
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
a4a3a60db7 feat:添加日志功能 2025-12-19 20:01:45 +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
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
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
de3b108503 fix:修复验证码验证时TTL被重置的问题
- 修复验证失败时TTL被重置为5分钟的bug
- 保持原有的过期时间,不重置验证码有效期
- 增加详细的TTL变化日志记录
- 改进错误处理和边界情况处理
- 解决用户验证一次错误后验证码立即过期的问题
2025-12-17 21:23:16 +08:00
moyin
eb7a022f5b feat:添加验证码服务
- 实现验证码生成、验证和管理功能
- 支持多种验证码类型(邮箱验证、密码重置、短信验证)
- 集成Redis缓存存储验证码
- 实现防刷机制:发送频率限制和每小时限制
- 支持验证码过期管理和尝试次数限制
- 包含完整的单元测试
2025-12-17 20:21:30 +08:00
moyin
3e5c171ff6 feat:添加邮件服务
- 实现完整的邮件发送功能
- 支持验证码邮件发送
- 支持欢迎邮件发送
- 集成SMTP配置和Nodemailer
- 添加邮件模板和HTML格式支持
- 包含完整的单元测试
2025-12-17 20:21:11 +08:00
moyin
a1669626fd fix:修复日志系统响应序列化器错误
- 修复res.getHeader is not a function错误
- 添加响应对象方法存在性检查
- 确保日志系统在各种响应类型下正常工作
2025-12-17 15:17:11 +08:00
moyin
8591f23505 chore:清理空的gitkeep文件和临时文件
- 删除不再需要的.gitkeep占位文件
- 清理开发过程中的临时测试文件
2025-12-17 11:03:40 +08:00
moyin
8fbfc0202b fix:修复Pino日志配置的Worker线程序列化问题
- 移除customPrettifiers中的箭头函数以避免DataCloneError
- 修复未使用参数的TypeScript警告
- 替换已弃用的substr方法为substring
2025-12-17 11:03:03 +08:00
moyin
2ce05931dd docs:修改模块时间 2025-12-17 10:18:37 +08:00
moyin
5353a956d1 chore:完善日志系统集成和依赖管理
- 更新日志模块集成新的配置和管理服务
- 添加定时任务依赖 @nestjs/schedule
- 更新 .gitignore 忽略日志文件和压缩文件
- 移除不兼容的日志轮转依赖
2025-12-13 16:44:25 +08:00
moyin
c6ca204fae feat:增强日志系统功能
- 新增高级日志配置工厂类,支持环境差异化配置
- 新增日志管理服务,提供定时清理和健康监控
- 支持生产环境多文件分类输出(app.log、error.log、access.log)
- 支持开发环境美化输出和文件备份
- 添加自动日志清理和统计功能
2025-12-13 16:44:18 +08:00
moyin
7ebc75e678 chore:优化项目目录结构
- 清理不必要的 .gitkeep 占位文件
- 保留必要目录的 .gitkeep 文件
- 统一项目文件组织结构
2025-12-13 16:20:13 +08:00
moyin
a3ea69d99a refactor:完善日志系统代码注释规范
- 添加完整的模块级、类级、方法级注释
- 优化类型定义和接口注释说明
- 增加详细的业务逻辑说明和使用示例
- 符合后端开发规范指南要求
2025-12-13 16:18:02 +08:00