Skip to content

Commit f07e71b

Browse files
committed
feat: add email normalization and disposable domain blocking via better-auth-harmony
1 parent c63fa90 commit f07e71b

7 files changed

Lines changed: 994 additions & 3 deletions

File tree

apps/api/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"@motis-project/motis-client": "^2.9.1",
3030
"@openstreetmap/id-tagging-schema": "^6.15.0",
3131
"better-auth": "^1.5.5",
32+
"better-auth-harmony": "^1.3.1",
3233
"cached-hafas-client": "^5.1.9",
3334
"db-vendo-client": "^6.10.8",
3435
"drizzle-orm": "^0.45.1",

apps/api/src/auth.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { passkey } from "@better-auth/passkey";
33
import { betterAuth } from "better-auth";
44
import { drizzleAdapter } from "better-auth/adapters/drizzle";
55
import { admin, emailOTP, genericOAuth, twoFactor } from "better-auth/plugins";
6+
import { emailHarmony } from "better-auth-harmony";
67
import { eq } from "drizzle-orm";
78
import { db } from "./db";
89
import { user as userTable } from "./db/schema";
@@ -135,6 +136,7 @@ export const auth = betterAuth({
135136
plugins: [
136137
admin(),
137138
expo(),
139+
emailHarmony({ allowNormalizedSignin: true }),
138140
passkey({
139141
rpID: process.env.PASSKEY_RP_ID ?? "localhost",
140142
rpName: "OpenMapX",

apps/api/src/db/auth-schema.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export const user = pgTable("user", {
1616
banned: boolean("banned").default(false),
1717
banReason: text("ban_reason"),
1818
banExpires: timestamp("ban_expires"),
19+
normalizedEmail: text("normalized_email").unique(),
1920
twoFactorEnabled: boolean("two_factor_enabled").default(false),
2021
});
2122

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE "user" ADD COLUMN "normalized_email" text;--> statement-breakpoint
2+
ALTER TABLE "user" ADD CONSTRAINT "user_normalized_email_unique" UNIQUE("normalized_email");

0 commit comments

Comments
 (0)