feat(auth) : protect admin login with turnstile
CI / Verify (push) Successful in 1m19s
CI / Build immutable images and deploy (push) Successful in 2m47s

This commit is contained in:
2026-09-10 21:39:07 +07:00 Unverified
parent 249af29e9b
commit e860425e08
5 changed files with 127 additions and 6 deletions
+10 -2
View File
@@ -3,7 +3,7 @@ import "server-only";
import { betterAuth } from "better-auth";
import { drizzleAdapter } from "better-auth/adapters/drizzle";
import { nextCookies } from "better-auth/next-js";
import { admin } from "better-auth/plugins";
import { admin, captcha } from "better-auth/plugins";
import { headers } from "next/headers";
import { getDb } from "@/db";
@@ -60,7 +60,15 @@ function createAuth() {
},
},
},
plugins: [admin({ defaultRole: "admin" }), nextCookies()],
plugins: [
captcha({
provider: "cloudflare-turnstile",
secretKey: required("TURNSTILE_SECRET_KEY"),
endpoints: ["/sign-in/email"],
}),
admin({ defaultRole: "admin" }),
nextCookies(),
],
});
}