From 389b8eca28f6f66e0a427369c69146254332412d Mon Sep 17 00:00:00 2001 From: kyx236 Date: Mon, 2 Feb 2026 11:14:20 +0800 Subject: [PATCH] 4 --- backend/internal/auth/codex_api.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/backend/internal/auth/codex_api.go b/backend/internal/auth/codex_api.go index e0f8ae9..12f81e0 100644 --- a/backend/internal/auth/codex_api.go +++ b/backend/internal/auth/codex_api.go @@ -494,8 +494,22 @@ func (c *CodexAPIAuth) ObtainAuthorizationCode() (string, error) { } c.logStep(StepInputPassword, "密码验证成功") - // 打印密码验证响应,看看服务器返回了什么 - c.logStep(StepInputPassword, "密码验证响应: %s", string(body[:min(500, len(body))])) + // 解析密码验证响应 + json.Unmarshal(body, &data) + + // 检查下一步是什么 + nextPageType := "" + if page, ok := data["page"].(map[string]interface{}); ok { + if pt, ok := page["type"].(string); ok { + nextPageType = pt + } + } + + // 如果需要邮箱验证,这是新账号的问题 + if nextPageType == "email_otp_verification" { + c.logError(StepInputPassword, "账号需要邮箱验证,无法继续 Codex 授权流程") + return "", fmt.Errorf("账号需要邮箱验证,请使用浏览器模式或等待账号状态更新") + } } else { c.logStep(StepInputPassword, "跳过密码验证步骤 (服务器未要求)") }