better-auth icon indicating copy to clipboard operation
better-auth copied to clipboard

feat(magic-link): require name for signup

Open ouariachi opened this issue 6 months ago • 4 comments

What changes were made and why:

  • Added a new configuration option requireNameForSignUp in the Magic Link plugin.
  • When enabled, any attempt to create a new user via Magic Link without a non-empty name field will fail.
  • This ensures new users always have a name, improving data consistency and preventing incomplete user records.
  • Updated the plugin documentation to include the new requireNameForSignUp option and describe its behavior.

Relevant context:

  • Currently, Magic Link signup allows creating users without a name.
  • The recommended workaround (from issue comment) was to collect name later, but adding native support avoids extra steps and simplifies the flow.

Breaking changes / deprecations:

  • No breaking changes.
  • Flows without requireNameForSignUp enabled remain unchanged.

Tests / screenshots:

  • Added test to verify that signup fails if name is missing when requireNameForSignUp is true.

Related issues / discussions:

  • Closes #5139

Summary by cubic

Added an option to require a non-empty name when creating new users via Magic Link signup. This prevents nameless accounts and improves data consistency.

  • New Features
    • Added requireNameForSignUp (default: false).
    • When enabled (and sign up isn’t disabled), new user signup without a non-empty name redirects with ?error=NAME_REQUIRED_FOR_SIGNUP.
    • Updated docs to cover the new option.

ouariachi avatar Oct 07 '25 04:10 ouariachi

@ouariachi is attempting to deploy a commit to the better-auth Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Oct 07 '25 04:10 vercel[bot]

Open in StackBlitz

better-auth

npm i https://pkg.pr.new/better-auth/better-auth@5140
@better-auth/cli

npm i https://pkg.pr.new/better-auth/better-auth/@better-auth/cli@5140
@better-auth/core

npm i https://pkg.pr.new/better-auth/better-auth/@better-auth/core@5140
@better-auth/expo

npm i https://pkg.pr.new/better-auth/better-auth/@better-auth/expo@5140
@better-auth/sso

npm i https://pkg.pr.new/better-auth/better-auth/@better-auth/sso@5140
@better-auth/stripe

npm i https://pkg.pr.new/better-auth/better-auth/@better-auth/stripe@5140
@better-auth/telemetry

npm i https://pkg.pr.new/better-auth/better-auth/@better-auth/telemetry@5140

commit: 5784a96

pkg-pr-new[bot] avatar Oct 07 '25 04:10 pkg-pr-new[bot]

I think you forgot to update your tests to use the lowercase error name, yet CI didn't fail. Is your test not working?

ping-maxwell avatar Oct 08 '25 13:10 ping-maxwell

I think you forgot to update your tests to use the lowercase error name, yet CI didn't fail. Is your test not working?

Yes, I was checking the error code in the signIn response when it should be in the verify response.

ouariachi avatar Oct 08 '25 14:10 ouariachi