Skip to content

feat(auth): add display name and new-account options to email sign-up - #1428

Open
demolaf wants to merge 4 commits into
mainfrom
auth/email-signup-options
Open

demolaf wants to merge 4 commits into
mainfrom
auth/email-signup-options

Conversation

@demolaf

@demolaf demolaf commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

Restores the v15 email sign-up options: sign-up can ask for a name and save it as the display name, and apps can turn sign-up off. Builds on #1414, so custom email screens get the new fields before the slot API ships.

Changes

  • withEmailSignIn(requireDisplayName:allowNewEmailAccounts:). requireDisplayName defaults to false so existing apps see no change (v15 and Android default to true); allowNewEmailAccounts defaults to true.
  • EmailAuthContentState gains a displayName binding plus requiresDisplayName and canSignUp, all with init defaults. isValid needs a non-blank name on sign-up when one is required.
  • The stock form shows a Name field on sign-up and hides the sign-up switch when sign-up is off. createUser(email:password:displayName:) saves the name before reporting the account signed in, and throws Firebase's own adminRestrictedOperation when sign-up is off, so AuthServiceError is unchanged.

API Usage

authService.withEmailSignIn(requireDisplayName: true, allowNewEmailAccounts: false)

EmailAuthScreen(flow: .signUp) { state in
  TextField("Email", text: state.email)
  if state.requiresDisplayName {
    TextField("Name", text: state.displayName)
  }
  SecureField("Password", text: state.password)
  SecureField("Confirm password", text: state.confirmPassword)
  Button("Create account", action: state.signUp)
    .disabled(!state.isValid || state.isLoading)
}

Preview


Maintainer note: Fixes internal CPRN-638, fixes internal CPRN-639

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request introduces configuration options to control whether email sign-up requires a display name and whether new email accounts can be created. It updates AuthService with new parameters, adds a display name input field to the sign-up UI, introduces a new error case for disallowed sign-ups, and updates the corresponding tests and documentation. There are no review comments provided, so I have no additional feedback to offer.

Base automatically changed from auth/email-content-slots to main November 9, 2026 14:32
@demolaf
demolaf force-pushed the auth/email-signup-options branch from 63cb099 to 2bd8362 Compare November 9, 2026 15:41
@demolaf
demolaf added this pull request to stack #1433 November 9, 2026 15:50
@demolaf
demolaf marked this pull request as ready for review November 10, 2026 14:25
Restores the FirebaseUI-iOS v15 email options. withEmailSignIn takes requireDisplayName (default true) and allowNewEmailAccounts (default true). EmailAuthContentState gains a displayName binding and requiresDisplayName and canSignUp flags, the stock form asks for a name on sign-up and hides the sign-up switch when sign-up is off, and createUser saves the name after creating or upgrading the account and throws emailSignUpNotAllowed when sign-up is off.
createUser reported the new account authenticated before saving its display name, and a failed save left the state unchanged. Save the name first and update the state either way. The stock Name field now rejects whitespace-only names with a message, matching isValid, and the docs note that email-link sign-in still creates accounts while sign-up is off.
Default requireDisplayName to false so the stock sign-up form is unchanged unless an app opts in, and refuse sign-up with Firebase's own adminRestrictedOperation error instead of a new AuthServiceError case, which would break exhaustive switches.
…eUser(email:password:)

The error thrown while sign-up is off now carries Firebase's error name and a localized message, so apps that read either get the same values as for the error Firebase returns. Restore the two-argument createUser so references to it still compile, and test that email sign-in doesn't require a name by default.
@demolaf
demolaf force-pushed the auth/email-signup-options branch from 3e1cd26 to d2d9a6f Compare November 10, 2026 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant