-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathauth.ts
More file actions
51 lines (50 loc) · 1.56 KB
/
auth.ts
File metadata and controls
51 lines (50 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { betterAuth } from "better-auth";
import { drizzleAdapter } from "better-auth/adapters/drizzle";
import { db } from "./src/db/drizzle"; // your drizzle instance
import { account, session, user, verification } from "@/db/schema/auth-schema";
import { sendPasswordResetEmail, sendVerificationEmail } from "./email";
export const auth = betterAuth({
database: drizzleAdapter(db, {
provider: "pg",
schema: {
user,
account,
session,
verification,
},
}),
emailAndPassword: {
enabled: true,
requireEmailVerification: true,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
sendResetPassword: async ({ user, url, token }, request) => {
await sendPasswordResetEmail({
to: user.email,
subject: "Reset your password",
text: `Click the link to reset your password: ${url}`,
});
},
},
socialProviders: {
github: {
clientId: process.env.GITHUB_CLIENT_ID as string,
clientSecret: process.env.GITHUB_CLIENT_SECRET as string,
},
google: {
clientId: process.env.GOOGLE_CLIENT_ID as string,
clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,
},
},
emailVerification: {
sendOnSignUp: true,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
sendVerificationEmail: async ({ user, url, token }, request) => {
await sendVerificationEmail({
to: user.email,
subject: "Verify your email address",
text: `Click the link to verify your email: ${url}`,
});
},
},
trustedOrigins: ["*"],
});