-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathauth.config.ts
56 lines (51 loc) · 1.23 KB
/
auth.config.ts
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
52
53
54
55
56
import {
accountsTable,
sessionsTable,
usersTable,
verificationTokensTable
} from "@/drizzle/schema"
import { HttpEmailProvider } from "@/lib/auth/http-email-provider"
import { DrizzleAdapter } from "@auth/drizzle-adapter"
import type { NextAuthConfig } from "next-auth"
import GitHub from "next-auth/providers/github"
import Google from "next-auth/providers/google"
import { db } from "./drizzle/client"
export default {
/**
* @see {@link https://authjs.dev/reference/adapter/drizzle}
*/
adapter: DrizzleAdapter(db, {
// @ts-expect-error custom citext column causes an error
usersTable,
accountsTable,
sessionsTable,
verificationTokensTable
}),
/**
*
*/
providers: [Google, GitHub, HttpEmailProvider],
/**
* Using JWTs for session tokens, so we can access the user's ID and email
* from edge networks without requiring database access (which may not be
* available in edge environments).
*/
session: { strategy: "jwt" },
/**
*
*/
callbacks: {
session({ session, token }) {
if (session.user && token.sub) {
session.user.id = token.sub
}
return session
}
},
/**
*
*/
pages: {
signIn: "/signin"
}
} satisfies NextAuthConfig