feat(auth): 防账号枚举 — 已注册邮箱发"已注册"提醒,不内联暴露

发码/注册都不再泄露"邮箱是否已注册"(对翻墙工具尤其敏感:已注册=该人是用户)。
- SendCode:邮箱已注册时不发验证码、改发"您已注册请直接登录"邮件,接口统一
  返回 204(注册/未注册无差别)→ 关掉发码侧枚举
- Register:命中已注册(ErrEmailTaken)改回通用 ErrCodeInvalid(与错码一致),
  不再返回"该邮箱已注册"→ 关掉注册侧枚举
- Mailer 接口加 SendAlreadyRegistered(SMTP + Log 两实现)
- 测试:DuplicateEmailConflict 改为断言"已注册不发码 + 强制码也只回通用错误";
  integration 同步

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
wangjia
2026-06-18 20:37:53 +08:00
parent d341c1c6e5
commit 81e7b12061
5 changed files with 85 additions and 9 deletions
+2
View File
@@ -133,6 +133,8 @@ func (m *captureMailer) SendCode(_ context.Context, to, code string) error {
return nil
}
func (m *captureMailer) SendAlreadyRegistered(_ context.Context, _ string) error { return nil }
func (m *captureMailer) codeFor(to string) string {
m.mu.Lock()
defer m.mu.Unlock()