debug(login): add detailed TOTP logging and field inspection
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 <noreply@anthropic.com>
This commit is contained in:
parent
becb692c2f
commit
1b15e6512e
@ -137,7 +137,12 @@ async function proxy<T>(
|
||||
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<T>(
|
||||
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<Response> {
|
||||
const loginBody: Record<string, string> = { 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<LoginResponse>('/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) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user