fix: handle MFA binding skip during registration submit

The registration flow hit a 422 on /api/experience/submit when MFA
policy is UserControlled. Adds the same trySubmit + skipMfaBinding
pattern already used in the sign-in flow — Logto confirms mfa-skipped
works for both SignIn and Register interaction events.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
hsiegeln
2026-04-26 15:52:46 +02:00
parent c55427c22b
commit 988035b952

View File

@@ -180,7 +180,19 @@ export async function completeRegistration(
const verifiedId = await verifyCode(email, verificationId, code);
await addProfile('password', password);
await identifyUser(verifiedId);
return submitInteraction();
const result = await trySubmit();
if (result.ok) return result.redirectTo;
// MFA not enrolled, UserControlled policy — skip the binding prompt
if (result.status === 422 && result.code.includes('mfa')) {
await skipMfaBinding();
const retry = await trySubmit();
if (retry.ok) return retry.redirectTo;
throw new Error(retry.message);
}
throw new Error(result.message);
}
// --- Forgot Password ---