Skip to content

Conversation

@ahmedriad1
Copy link
Contributor

@ahmedriad1 ahmedriad1 commented Oct 26, 2025

Screen.Recording.2025-10-26.at.5.56.39.PM.mov

I found out creating invites using the organization plugin doesn't validate emails agentset-ai/agentset#34

I looked more into the codebase and found it's missing in other places too. So I made this PR that does the following:

  1. Validate email when creating invites (organization plugin)
  2. Validate email when creating users as admin (admin plugin)
  3. Refactor email validation to use zod instead of manual regex & remove redundant error codes that already exist in BASE_ERROR_CODES (email-otp plugin)

Summary by cubic

Add email validation to organization invites and admin user creation, and standardize email handling and errors in email-otp. Prevents invalid invites/sign-ups and ensures consistent error messages.

  • Bug Fixes

    • Validate emails when creating organization invites.
    • Validate emails when admins create users.
    • Lowercase emails before lookup and creation to prevent duplicates.
  • Refactors

    • Replace manual regex with zod email validation in email-otp.
    • Use BASE_ERROR_CODES for INVALID_EMAIL and USER_NOT_FOUND; remove redundant local codes.

@vercel
Copy link

vercel bot commented Oct 26, 2025

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

A member of the Team first needs to authorize it.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 26, 2025

Open in StackBlitz

better-auth

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

@better-auth/cli

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

@better-auth/core

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

@better-auth/expo

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

@better-auth/sso

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

@better-auth/stripe

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

@better-auth/telemetry

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

commit: abc5cf8

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 3 files

@ping-maxwell
Copy link
Member

@ahmedriad1 make sure to run pnpm lint:fix!

@ahmedriad1
Copy link
Contributor Author

@ping-maxwell Done

@ping-maxwell
Copy link
Member

cc @himself65 @Bekacru

@himself65 himself65 added this pull request to the merge queue Oct 27, 2025
Merged via the queue into better-auth:canary with commit 8503c2b Oct 27, 2025
9 of 12 checks passed
himself65 pushed a commit that referenced this pull request Oct 27, 2025
Co-authored-by: Maxwell <145994855+ping-maxwell@users.noreply.github.com>
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.

3 participants