mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2026-10-27 02:16:23 -04:00
Names and avatars come from GitHub at sign-up; prevent signed-in users from renaming themselves to impersonate other commenters. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
import { drizzleAdapter } from "@better-auth/drizzle-adapter/relations-v2";
|
|
import { dash } from "@better-auth/infra";
|
|
import { waitUntil } from "@vercel/functions";
|
|
import { type BetterAuthOptions, betterAuth } from "better-auth/minimal";
|
|
import { nextCookies } from "better-auth/next-js";
|
|
|
|
import { db } from "@/lib/db";
|
|
import * as schema from "@/lib/db/schema";
|
|
|
|
export const auth = betterAuth({
|
|
appName: "jarv.is",
|
|
baseURL: process.env.NEXT_PUBLIC_BASE_URL,
|
|
database: drizzleAdapter(db, {
|
|
provider: "pg",
|
|
schema,
|
|
}),
|
|
plugins: [dash(), nextCookies()],
|
|
// names and avatars come from GitHub at sign-up; don't let users rename themselves (e.g. to impersonate someone)
|
|
disabledPaths: ["/update-user"],
|
|
socialProviders: {
|
|
github: {
|
|
clientId: process.env.GITHUB_CLIENT_ID!,
|
|
clientSecret: process.env.GITHUB_CLIENT_SECRET!,
|
|
mapProfileToUser: (profile) => ({
|
|
name: profile.login,
|
|
email: profile.email,
|
|
emailVerified: true,
|
|
image: profile.avatar_url,
|
|
}),
|
|
},
|
|
},
|
|
advanced: {
|
|
database: {
|
|
joins: true,
|
|
},
|
|
backgroundTasks: {
|
|
handler: waitUntil,
|
|
},
|
|
ipAddress: {
|
|
ipAddressHeaders: ["x-vercel-forwarded-for", "x-forwarded-for"],
|
|
},
|
|
},
|
|
} satisfies BetterAuthOptions);
|