Transform email to lowercase in invite schema in organization plugin #585

Closed
opened 2026-03-13 07:54:53 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @AJNandi on GitHub (Jan 23, 2025).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

Noticed a bug where sending an invite with a capitalized email is stored with the capitalization in the invite table. When that user signs up/in, the user table sets the email to lowercase, and the non-capitalized email isn't able to find the invitation.

Looks like the organization invite schema should also transform the invite email to be lowercase, as it does in the user schema.

184733a08c/packages/better-auth/src/plugins/organization/schema.ts (L33)

Current vs. Expected behavior

I expected the sendInvitationEmail function on the organization plugin to set the email to lowercase automatically.

What version of Better Auth are you using?

1.1.11

Provide environment information

macOS, chrome, safari.

Which area(s) are affected? (Select all that apply)

Backend, Client

Auth config (if applicable)

export const auth = betterAuth({
  database: new Database("./sqlite.db"),
  trustedOrigins: ["http://localhost:5173"],
  plugins: [
    organization({
      sendInvitationEmail: async (data) => {
        const inviteLink = `http://localhost:5173/invite/${data.id}`
        console.log("inviteLink:", inviteLink)
      },
    }),
    openAPI(),
    emailOTP({
      async sendVerificationOTP({ email, otp, type }) {
          console.log("Sending OTP for sign-in", otp, email)
      },
    }),
  ],
})

Additional context

No response

Originally created by @AJNandi on GitHub (Jan 23, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce Noticed a bug where sending an invite with a capitalized email is stored with the capitalization in the invite table. When that user signs up/in, the user table sets the email to lowercase, and the non-capitalized email isn't able to find the invitation. Looks like the organization invite schema should also transform the invite email to be lowercase, as it does in the user schema. https://github.com/better-auth/better-auth/blob/184733a08cf1898cec5e0c4b9208a6424386c47a/packages/better-auth/src/plugins/organization/schema.ts#L33 ### Current vs. Expected behavior I expected the sendInvitationEmail function on the organization plugin to set the email to lowercase automatically. ### What version of Better Auth are you using? 1.1.11 ### Provide environment information ```bash macOS, chrome, safari. ``` ### Which area(s) are affected? (Select all that apply) Backend, Client ### Auth config (if applicable) ```typescript export const auth = betterAuth({ database: new Database("./sqlite.db"), trustedOrigins: ["http://localhost:5173"], plugins: [ organization({ sendInvitationEmail: async (data) => { const inviteLink = `http://localhost:5173/invite/${data.id}` console.log("inviteLink:", inviteLink) }, }), openAPI(), emailOTP({ async sendVerificationOTP({ email, otp, type }) { console.log("Sending OTP for sign-in", otp, email) }, }), ], }) ``` ### Additional context _No response_
GiteaMirror added the bug label 2026-03-13 07:54:53 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#585