Files
jiapu/docs/superpowers/plans/2026-07-10-auth-form-validation-normalization.md
T
2026-07-10 17:08:22 +08:00

27 lines
1.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 2026-07-10 认证页表单校验和结构规范化计划
- 计划编号:PC-024
- 开始时间:2026-07-10 14:56:08 +08:00
- 页面范围:`login.html``register.html``forgot-password.html`
- 接口范围:登录、短信登录、注册、找回密码提交前的本地校验与验证码取票据
## 结论
- 当前三页只有很弱的前端校验,主要是必填判断和找回密码两次密码一致校验,不算完整表单验证。
- `<form>` 标签不是落后写法,它是提交类页面的语义结构;但把 `data-captcha-scene``data-success-url` 这类业务配置写在 HTML 上不够集中,后续维护容易散。
## 执行清单
1. [x] 写失败测试:认证页不能继续把业务配置写在表单 `data-*` 属性上。
2. [x] 写失败测试:认证页 JS 要提供统一表单校验函数。
3. [x] HTML 表单改为使用 `id` 作为挂载点。
4. [x] `auth-pages.js` 增加统一表单配置和校验函数。
5. [x] 保持三页提交前统一走 `CaptchaPages.ensureToken`,并继续使用 `payload.track` 换取票据。
6. [x] 运行结构测试、业务测试、验证码测试、语法检查和空白检查。
## 验证记录
- 2026-07-10 14:56:08 +08:00:开始记录 PC-024,并补充结构和校验测试。
- 2026-07-10 14:56:08 +08:00`node tests\auth-page-structure.test.js``node tests\auth-pages.test.js` 已按预期失败,失败点为 HTML 未使用表单 `id`、JS 缺少 `sms-login` 场景配置和统一校验函数。
- 2026-07-10 15:11:49 +08:00:修复后 `node tests\auth-page-structure.test.js``node tests\auth-pages.test.js``node tests\captcha-pages.test.js``node --check public\js\auth-pages.js``node --check public\js\captcha-pages.js` 均通过;`git diff --check` 无空白错误,仅有 LF/CRLF 换行提示。