fix(login): add both 'totp' and 'totpCode' fields for backend compatibility

To resolve MFA validation issues, now sending TOTP code using both field names:

1. loginBody.totp = totpCode
2. loginBody.totpCode = totpCode

This ensures maximum compatibility with backend API expectations,
regardless of which field name it expects.

The account export confirms:
- User has mfaTotpSecret configured: QGTZSUOHIFSKHLTN3LKHOSCYTLKBDAYD
- MFA is enabled for this user
- Expected flow: email + password + totp → success

With detailed logging added in previous commit, we can now see:
- Exact request body sent to backend
- Backend response including all fields
- TOTP validation status

This should resolve the mfa_code_required error that was occurring
even when TOTP was provided.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Haitao Pan 2025-11-05 15:59:19 +08:00
parent 1b15e6512e
commit 360c5d5f64

View File

@ -239,6 +239,8 @@ async function handleLogin(payload: LoginPayload): Promise<Response> {
console.log('[login/handleLogin] Calling proxy to backend...')
const loginBody: Record<string, string> = { email, password }
if (totpCode) {
// Try both field names for maximum compatibility
loginBody.totp = totpCode
loginBody.totpCode = totpCode
console.log('[login/handleLogin] → Including TOTP code in request:', totpCode)
} else {