Skip to content

feat(experience): enroll existing email or phone for MFA - #10029

Open
wangsijie wants to merge 3 commits into
wangsijie-explicit-mfa-onboarding-and-suggestionfrom
wangsijie-log-14721-core-experience-enroll-an-existing-email
Open

wangsijie wants to merge 3 commits into
wangsijie-explicit-mfa-onboarding-and-suggestionfrom
wangsijie-log-14721-core-experience-enroll-an-existing-email

Conversation

@wangsijie

@wangsijie wangsijie commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Implements LOG-14721, PR 2c of "MFA: Explicit email/SMS factor enrollment" (stacked on #10032).

  • Identifier MFA binding orchestration: add useStartIdentifierMfaBinding and Experience MFA / shared subject-verification-code API helpers to reuse a verified registration verification-code record when enrolling that same identifier during sign-up without sending a second code, or otherwise send a subject-bound primary verification code before navigating to /mfa-binding/<factor>.
  • Existing-identifier verification UI & factor list: reuse MfaCodeVerification (with bindMfaByVerificationCode and sendSubjectVerificationCode) on /mfa-binding/EmailVerificationCode and /mfa-binding/PhoneVerificationCode when maskedIdentifiers is present (preserving IdentifierProfileForm when absent), and use boundFactors in MfaFactorList so unenrolled existing primary identifiers remain selectable on session.mfa.suggest_additional_mfa.

Testing

Tested locally, Unit tests

MFA onboarding factor list with existing email

Checklist

  • .changeset
  • unit tests
  • integration tests
  • necessary TSDoc comments

@charIeszhao charIeszhao left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two findings from the MFA compatibility review.

@wangsijie
wangsijie force-pushed the wangsijie-log-14721-core-experience-enroll-an-existing-email branch from 022bc49 to 5d03df7 Compare November 17, 2026 06:38
@wangsijie wangsijie changed the title feat(core,experience): enroll existing email or phone for MFA feat(experience): enroll existing email or phone for MFA Nov 17, 2026
@wangsijie
wangsijie changed the base branch from wangsijie-log-14720-schemas-core-emailsms-mfa-records to wangsijie-explicit-mfa-onboarding-and-suggestion November 17, 2026 06:38
@github-actions github-actions Bot added size/xl and removed size/xl labels Nov 17, 2026
Comment on lines +79 to +82
await handleError(submitError, {
...trustedDeviceRegisterErrorHandler,
...submitErrorHandlers,
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Register trusted-device handler is spread first, so when called from MfaFactorList it's overridden by the SignIn one inside useMfaSubmitErrorHandler, but from the single-factor path in useMfaErrorHandler (which passes only the MFA handlers) it's the one that runs. The same session.trusted_device_suggest_opt_in response then puts a different interactionEvent into the trusted-device state depending on where the user came from.

use-mfa-submit-error-handler.ts notes that MFA binding after registration continues as SignIn. Can we drop the Register handler here and use useMfaSubmitErrorHandler for both callers?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched useTrustedDeviceOptInErrorHandler here to InteractionEvent.SignIn so both callers produce the same SignIn continuation state. Kept the MFA handlers passed via submitErrorHandlers rather than calling useMfaSubmitErrorHandler directly here because useMfaErrorHandler invokes useStartIdentifierMfaBinding, which would otherwise create a circular hook call.

Comment on lines +108 to +114
if (
(factor === MfaFactor.EmailVerificationCode ||
factor === MfaFactor.PhoneVerificationCode) &&
flow === UserMfaFlow.MfaBinding
) {
return startIdentifierMfaBinding(factor, state);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With a single available factor this now starts the binding right away. In Register (Mandatory + Explicit with only email/phone configured, or WebAuthn filtered out in a native webview) and a verified registration code, the factor is enrolled and the interaction submitted without any MFA screen, so the user never sees that email MFA was turned on, nor a skip button when it's skippable. Previously this navigated to the binding page.

Is that the intended UX?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is intended: (1) when MFA is skippable (non-mandatory policies), Core throws user.suggest_mfa (/mfa-onboarding with Enable + Skip) before reaching user.missing_mfa, so the user never loses the skip choice; (2) under non-skippable Mandatory policies with only a single usable factor, SignIn needs startIdentifierMfaBinding to send the code and obtain verificationId before rendering the code input (matching startTotpBinding / startWebAuthnProcessing), and in Register reusing the just-verified registration code completes mandatory enrollment without a redundant screen, matching Implicit mode.

@github-actions github-actions Bot added size/xl and removed size/xl labels Nov 17, 2026
- Reuse verified registration code records when enrolling the same identifier
  during sign-up, or send a subject-bound primary verification code.
- Render ExistingIdentifierCodeVerification when maskedIdentifiers is present
  and use boundFactors in MfaFactorList to keep unenrolled identifiers active.

Implements LOG-14721.
- Share isFactorBoundInSuggestion across MfaFactorList, useMfaErrorHandler,
  and useStartIdentifierMfaBinding so single-factor suggestions left after
  WebView WebAuthn filtering land on /mfa-binding instead of re-enrolling.
- Exercise real redirect and identifier-binding hooks together in tests.
…llback

- Share sendSubjectVerificationCode and verifySubjectVerificationCode between
  step-up and MFA binding APIs, and reuse MfaCodeVerification for existing
  identifier code entry instead of a duplicate component.
- Fall back to sending a primary code only on email/phone_exists_in_profile
  errors, and align trusted-device opt-in continuation on SignIn.
@wangsijie
wangsijie force-pushed the wangsijie-explicit-mfa-onboarding-and-suggestion branch from 21dfd96 to bba0ba8 Compare November 17, 2026 08:15
@wangsijie
wangsijie force-pushed the wangsijie-log-14721-core-experience-enroll-an-existing-email branch from 2be5da0 to 7984423 Compare November 17, 2026 08:15
@github-actions github-actions Bot added size/xl and removed size/xl labels Nov 17, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

3 participants