From 1b15e6512e9a3edc3e2bb07f617e6b915208fd3a Mon Sep 17 00:00:00 2001 From: Haitao Pan Date: Wed, 5 Nov 2025 15:58:16 +0800 Subject: [PATCH] debug(login): add detailed TOTP logging and field inspection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added comprehensive debugging information for login flow to diagnose TOTP validation issues: 1. In proxy function: - Log TOTP presence before sending to backend - Log detailed response including hasToken, hasMfaToken, error - Show exact field values being sent 2. In handleLogin function: - Log TOTP code inclusion in request body - Log full request body structure - Log complete backend response data (JSON formatted) This will help identify whether TOTP is being sent correctly and what error responses the backend is returning. Expected next steps based on logs: - Verify backend receives correct TOTP field name - Check if TOTP code format matches backend expectations - Identify why backend returns mfa_code_required 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- dashboard-fresh/routes/api/auth/login.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/dashboard-fresh/routes/api/auth/login.ts b/dashboard-fresh/routes/api/auth/login.ts index c82bd75..d2692a2 100644 --- a/dashboard-fresh/routes/api/auth/login.ts +++ b/dashboard-fresh/routes/api/auth/login.ts @@ -137,7 +137,12 @@ async function proxy( const authUrl = await getAuthUrl() const url = `${authUrl}${endpoint}` - console.log(`[login-proxy] → ${endpoint}`, { email: body.email || 'N/A' }) + console.log(`[login-proxy] → ${endpoint}`, { + email: body.email || 'N/A', + hasPassword: !!body.password, + hasTotp: !!body.totpCode, + totp: body.totpCode || 'N/A', + }) try { const response = await fetch(url, { @@ -154,6 +159,9 @@ async function proxy( console.log(`[login-proxy] ← ${endpoint} [${response.status}]`, { ok: response.ok, hasData: !!data, + hasToken: !!data?.token, + hasMfaToken: !!data?.mfaToken, + error: data?.error, }) return { @@ -232,11 +240,17 @@ async function handleLogin(payload: LoginPayload): Promise { const loginBody: Record = { email, password } if (totpCode) { loginBody.totpCode = totpCode + console.log('[login/handleLogin] → Including TOTP code in request:', totpCode) + } else { + console.log('[login/handleLogin] → No TOTP code provided') } + console.log('[login/handleLogin] → Request body:', loginBody) + const { ok, status, data } = await proxy('/api/auth/login', loginBody) console.log('[login/handleLogin] Backend response - ok:', ok, 'status:', status) + console.log('[login/handleLogin] Backend response data:', JSON.stringify(data, null, 2)) // Successful login with token if (ok && data?.token) {