Email column of user table is case sensitive, #429

Closed
opened 2026-03-13 07:45:31 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @EthanITA on GitHub (Dec 18, 2024).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

Using only Google social sign in, I just noticed that a person has 2 "User" with the same email, the only difference is one starts with a capital "S", and the other one in lowercase "s"

Current vs. Expected behavior

It should be case insensitive

What version of Better Auth are you using?

1.0.22

Provide environment information

- MacOS
- pnpm
- Drizzle ORM
- generated with the cli and then adapted the schema

export const user = pgTable("user", {
  id: text().primaryKey(),
  name: text().notNull(),
  email: text().notNull().unique(),
  emailVerified: boolean().notNull(),
  image: text(),
  role: text().$type<"user" | "admin">().default("user"),
  banned: boolean("banned"),
  banReason: text("banReason"),
  banExpires: timestamp("banExpires"),
  ...timestamps,
});

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

Backend

Auth config (if applicable)

import { betterAuth } from "better-auth";
import { drizzleAdapter } from "better-auth/adapters/drizzle";
import { db } from "./drizzle";
import { admin, passkey } from "better-auth/plugins";
import { useEnv } from "./env";

export const auth = betterAuth({
  database: drizzleAdapter(db, {
    provider: "pg",
  }),
  emailAndPassword: {
    enabled: true,
  },
  socialProviders: {
    google: {
      clientId: useEnv.GOOGLE_CLIENT_ID,
      clientSecret: useEnv.GOOGLE_CLIENT_SECRET,
    },
  },
  plugins: [passkey(), admin()],
});

Additional context

No response

Originally created by @EthanITA on GitHub (Dec 18, 2024). ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce Using only Google social sign in, I just noticed that a person has 2 "User" with the same email, the only difference is one starts with a capital "S", and the other one in lowercase "s" ### Current vs. Expected behavior It should be case insensitive ### What version of Better Auth are you using? 1.0.22 ### Provide environment information ```bash - MacOS - pnpm - Drizzle ORM - generated with the cli and then adapted the schema export const user = pgTable("user", { id: text().primaryKey(), name: text().notNull(), email: text().notNull().unique(), emailVerified: boolean().notNull(), image: text(), role: text().$type<"user" | "admin">().default("user"), banned: boolean("banned"), banReason: text("banReason"), banExpires: timestamp("banExpires"), ...timestamps, }); ``` ### Which area(s) are affected? (Select all that apply) Backend ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth"; import { drizzleAdapter } from "better-auth/adapters/drizzle"; import { db } from "./drizzle"; import { admin, passkey } from "better-auth/plugins"; import { useEnv } from "./env"; export const auth = betterAuth({ database: drizzleAdapter(db, { provider: "pg", }), emailAndPassword: { enabled: true, }, socialProviders: { google: { clientId: useEnv.GOOGLE_CLIENT_ID, clientSecret: useEnv.GOOGLE_CLIENT_SECRET, }, }, plugins: [passkey(), admin()], }); ``` ### Additional context _No response_
GiteaMirror added the bug label 2026-03-13 07:45:31 -05:00
Author
Owner

@daveycodez commented on GitHub (Dec 18, 2024):

Ooooof good catch. Maybe can be addressed with databaseHooks

@daveycodez commented on GitHub (Dec 18, 2024): Ooooof good catch. Maybe can be addressed with databaseHooks
Author
Owner

@Bekacru commented on GitHub (Dec 19, 2024):

we actually do normalize emails https://github.com/better-auth/better-auth/blob/main/packages/better-auth/src/oauth2/link-account.ts#L102

@Bekacru commented on GitHub (Dec 19, 2024): we actually do normalize emails https://github.com/better-auth/better-auth/blob/main/packages/better-auth/src/oauth2/link-account.ts#L102
Author
Owner

@EthanITA commented on GitHub (Dec 19, 2024):

we actually do normalize emails https://github.com/better-auth/better-auth/blob/main/packages/better-auth/src/oauth2/link-account.ts#L102

It’s a commit of Dec 6, then I guess it was caused because I recently updated the library. Thank you!

@EthanITA commented on GitHub (Dec 19, 2024): > we actually do normalize emails https://github.com/better-auth/better-auth/blob/main/packages/better-auth/src/oauth2/link-account.ts#L102 It’s a commit of Dec 6, then I guess it was caused because I recently updated the library. Thank you!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#429