From f0a0c9c0c09ef4f9399d09132e6837fba704745e Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 8 Nov 2026 12:21:10 +0000 Subject: [PATCH] fix(auth): draw the phone way in on first paint when email+password is off and no single sign-on exists With the password door shut, LoginForm collapsed into the single sign-on view whether or not single sign-on existed, so a phone-only deployment showed "Use a password instead" and then "Back to single sign-on". The form is now drawn on first paint when no SSO is offered or enforced and phone sign-in is advertised; the identifier reads "Phone number", an OTP-only server opens on the verification-code step, and the back button is only drawn where single sign-on exists. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01QsR2jTpDZ3S2UNafH1sonG --- .changeset/31492-phone-only-login-card.md | 16 ++ ui/packages/auth/src/LoginForm.tsx | 76 ++++++--- .../__tests__/noSignInMethod-29159.test.tsx | 150 +++++++++++++++++- 3 files changed, 217 insertions(+), 25 deletions(-) create mode 100644 .changeset/31492-phone-only-login-card.md diff --git a/.changeset/31492-phone-only-login-card.md b/.changeset/31492-phone-only-login-card.md new file mode 100644 index 00000000000..7fd83c27bf7 --- /dev/null +++ b/.changeset/31492-phone-only-login-card.md @@ -0,0 +1,16 @@ +--- +'@object-ui/auth': patch +--- + +fix(auth): with email+password sign-in off, phone sign-in on and no single sign-on, the login card draws the phone way in on first paint instead of a single sign-on view + +Clause-②: no +Metadata-protocol: none + +`LoginForm` collapsed into the single sign-on view whenever the server turned email+password sign-in off (`emailPassword.enabled: false`), whether or not single sign-on existed. A deployment that signs in by phone only showed its users "Use a password instead" and, behind it, a "Back to single sign-on" button with no single sign-on anywhere. Now, with the password door shut, no single sign-on offered (`features.sso`) or enforced (`features.ssoEnforced`) and a phone way in advertised (`features.phoneNumber` or `features.phoneNumberOtp`), the form is drawn on first paint: + +- the identifier field reads "Phone number" (the existing `phoneLabel` / `phonePlaceholder` labels), since the server refuses an email address; +- with phone OTP the only way in, the form opens on the verification-code step and offers no switch to a password form the server refuses; +- no "Back to single sign-on" button, no sign-up link and no password-form description, all of which name a door the server refuses. + +A shut password door with single sign-on offered, declared enforcement, the no-method state and a failed config fetch (the password form, break-glass) are unchanged. diff --git a/ui/packages/auth/src/LoginForm.tsx b/ui/packages/auth/src/LoginForm.tsx index 6118e7f4aa6..af50e01512f 100644 --- a/ui/packages/auth/src/LoginForm.tsx +++ b/ui/packages/auth/src/LoginForm.tsx @@ -336,16 +336,30 @@ export function LoginForm({ }; }, [getAuthConfig]); + // A phone way in the server advertises: phone+password, or phone OTP. + const phoneSignInOffered = phonePasswordEnabled || phoneOtpEnabled; // Under enforced mode, and when the server has turned the password door off, // the password form is collapsed until the user opts into the break-glass - // path; otherwise it's always shown. - const passwordFormCollapsed = ssoEnforced || passwordSignInOff; + // path; otherwise it's always shown. One exception: the password door shut + // with no single sign-on offered but a phone way in. The form then holds the + // way in (phone+password, phone OTP), so it is drawn on first paint; a + // collapsed view there would be a single sign-on view with no single + // sign-on in it. + const passwordFormCollapsed = + ssoEnforced || (passwordSignInOff && (ssoEnabled || !phoneSignInOffered)); const passwordFormVisible = !passwordFormCollapsed || showPasswordFallback; // The break-glass link reveals the password form, so it is offered only // while that form holds a password door the server accepts: email+password // itself, or phone+password sign-in. The SSO button needs no link: the // SSO-only view draws it on first paint (`ssoEmailFormVisible` below). const breakGlassOffered = !passwordSignInOff || phonePasswordEnabled; + // The form's mode as drawn: with no password door the server accepts, the + // only way the form can hold is phone OTP, so it opens there and offers no + // switch back to a password form the server refuses. + const formMode = breakGlassOffered ? mode : 'phone-otp'; + // The identifier field names only what the server accepts: with email + // sign-in refused, a phone number is the one identifier left. + const phoneOnlyIdentifier = passwordSignInOff && phonePasswordEnabled; // Nothing the server advertises lets anyone in: say so, instead of SSO copy // with no SSO affordance and a password link the server refuses. const noSignInMethod = @@ -407,7 +421,7 @@ export function LoginForm({ // that the server rejects as "Invalid email" (#3238) — trim before use. const identifier = email.trim(); try { - if (mode === 'phone-otp') { + if (formMode === 'phone-otp') { await signInWithPhoneOtp(phone.trim(), otpCode.trim()); } else if (phonePasswordEnabled && looksLikePhoneIdentifier(identifier)) { // Unified identifier: a phone-shaped entry routes to phone+password. @@ -570,7 +584,10 @@ export function LoginForm({ ? ssoOnlyCopy ? l.ssoOnlyDescription : undefined - : description + : passwordSignInOff + ? // The password-form copy names a door the server refuses. + undefined + : description } /> )} @@ -607,7 +624,7 @@ export function LoginForm({ /> {passwordFormVisible ? ( - mode === 'phone-otp' ? ( + formMode === 'phone-otp' ? ( /* Phone-OTP sign-in (framework#2780): request a code, then verify. Server-side the number is guarded by a per-number cooldown + hourly cap — the resend button mirrors it with a countdown. */ @@ -674,13 +691,15 @@ export function LoginForm({ {isLoading ? l.submittingButton : l.submitButton} - + {breakGlassOffered && ( + + )} ) : (
@@ -691,15 +710,26 @@ export function LoginForm({
setEmail(e.target.value)} required @@ -783,8 +813,12 @@ export function LoginForm({ )} - {/* Break-glass form was opened under enforced mode — let the user - collapse back to the SSO-only view. */} + {/* Break-glass form was opened from the collapsed view — let the + user collapse back to it. The form is collapsed only where single + sign-on is enforced or offered (a shut password door with a phone + way in and no SSO draws the form on first paint), and the link + that opens it is offered only with a password door, so there is + always single sign-on to go back to. */} {passwordFormCollapsed && showPasswordFallback && (