fix: Redis session env fix + JWT import path fix (登录失败根因修复) #52

Merged
xiaoxia merged 2 commits from hotfix/redis-session-env-fix into develop 2026-06-27 17:18:11 +08:00
Owner

修复内容

  1. 环境变量名统一: ENABLE_REDIS_SESSIONENABLE_REDIS_SESSIONS (config.py, dependencies.py, .env)
  2. Redis bind 修复: 127.0.0.10.0.0.0 (允许跨容器连接)
  3. JWT 导入路径修复: from packages.config.settings import settingsfrom app.config import settings (jwt_service.py 第232行)

根因分析

登录返回401的根因是 jwt_service.py 中引用了不存在的模块路径 packages.config.settings,导致 JWT token 生成时抛出 ModuleNotFoundError,被 except 捕获后返回通用错误 "邮箱或密码错误"。

测试

  • 登录测试通过:POST /api/v1/auth/login 返回有效 access_token
## 修复内容 1. **环境变量名统一**: `ENABLE_REDIS_SESSION` → `ENABLE_REDIS_SESSIONS` (config.py, dependencies.py, .env) 2. **Redis bind 修复**: `127.0.0.1` → `0.0.0.0` (允许跨容器连接) 3. **JWT 导入路径修复**: `from packages.config.settings import settings` → `from app.config import settings` (jwt_service.py 第232行) ## 根因分析 登录返回401的根因是 jwt_service.py 中引用了不存在的模块路径 `packages.config.settings`,导致 JWT token 生成时抛出 ModuleNotFoundError,被 except 捕获后返回通用错误 "邮箱或密码错误"。 ## 测试 - 登录测试通过:POST /api/v1/auth/login 返回有效 access_token
xiaoxia added 2 commits 2026-06-27 17:18:05 +08:00
fix: 统一 ENABLE_REDIS_SESSIONS 命名,修复登录因 AttributeError 导致 500
CI/CD Pipeline / Validate Code Quality And Tests (push) Has been cancelled
CI/CD Pipeline / Frontend Lint (push) Has been cancelled
e068e301a1
fix: 修复 jwt_service.py 错误的 settings 导入路径导致登录 401
CI/CD Pipeline / Validate Code Quality And Tests (push) Has been cancelled
CI/CD Pipeline / Frontend Lint (push) Has been cancelled
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Has been cancelled
CI/CD Pipeline / Frontend Lint (pull_request) Has been cancelled
88c02e1532
- packages.config.settings 模块不存在,改为 from app.config import settings
- 此 bug 导致 JWT token 生成时 ModuleNotFoundError,被 except 捕获后返回通用 401
xiaoxia merged commit 70fe068fd3 into develop 2026-06-27 17:18:11 +08:00
Sign in to join this conversation.