Commit Graph
2 Commits
Author SHA1 Message Date
snowy-yang cd0f1f78a3 refactor: 迁移收尾(管理员2FA)+ 抽取公共工具层,消除 router 间重复
补齐最后缺口:
- POST /api/v1/auth/admin_login/email、/auth/admin_login/verify(管理员 2FA Step2/3),
  复用 auth_routes 的票据表与尝试上限(跨栈共享),签发会话 Cookie

重构(消除约 200 行重复,11 个 router 受益):
- web/request_utils.py:request_data / safe_int / extract_id / cookies / dedup_ids
  原在各 router 各复制一份,现集中
- web/serializers.py:format_credits / user_public / record_req_log
- 各 router 改为导入别名,行为逐字不变

覆盖率:Flask 90 条业务路由全部有 FastAPI 等价端点(含 5 个向后兼容别名)。
验证:pytest 69/69;ruff All checks passed;pyright 0 errors;奇偶 36/36;冒烟 10/10。
2026-09-26 10:20:46 +08:00
snowy-yang 18c77296c2 feat(routes): 迁移首页/静态资源 + /auth/me 认证状态
- web/routers/index.py:GET / 首页,用 Jinja2 以 Flask 同口径渲染
  (keep_trailing_newline=False)——输出与 Flask render_template 逐字节一致
- web/app.py:挂载 /static 静态资源(site_auth.js 等,与 Flask 同目录)
- web/routers/auth_status.py:/api/v1/auth/me 认证状态
  · user/duration_text/announcement/smtp_configured/register_credits 逐字段对齐
- core/repo.py:补 get_announcement / get_smtp_config / smtp_configured 异步读

契约奇偶校验:28 项全 OK(新增 index 逐字节、auth:me);
验证:pytest 51/51;ruff All checks passed;pyright 0 errors;
uvicorn 实跑 / 与 /static 与 /api/v1/* 均 200。
2026-09-26 09:51:32 +08:00