forked from dig-dao/simplegrants
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path[...nextauth].ts
75 lines (72 loc) · 2.17 KB
/
[...nextauth].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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import { PrismaAdapter } from "@next-auth/prisma-adapter"
import NextAuth from "next-auth"
import GoogleProvider from "next-auth/providers/google"
import FacebookProvider from "next-auth/providers/facebook"
import TwitterProvider from "next-auth/providers/twitter"
import prisma from "../../../lib/prismadb"
export const authOptions = {
adapter: PrismaAdapter(prisma),
providers: [
// TwitterProvider({
// clientId: process.env.TWITTER_CLIENT_ID || "",
// clientSecret: process.env.TWITTER_CLIENT_SECRET || "",
// version: "2.0", // opt-in to Twitter OAuth 2.0
// }),
GoogleProvider({
clientId: process.env.GOOGLE_CLIENT_ID || "",
clientSecret: process.env.GOOGLE_CLIENT_SECRET || "",
httpOptions: {
timeout: 100000,
},
}),
// FacebookProvider({
// clientId: process.env.FACEBOOK_CLIENT_ID || "",
// clientSecret: process.env.FACEBOOK_CLIENT_SECRET || "",
// }),
],
callbacks: {
async session({ session, token, user }: any) {
// Adding the user ID here so we can retrieve the user in the backend
session.user.id = user?.id
return session
},
},
pages: {
signIn: "/sign-in",
},
cookies:
process.env.NODE_ENV === "production"
? {
sessionToken: {
name: `__Secure-next-auth.session-token`,
options: {
httpOnly: true,
sameSite: "None",
path: "/",
secure: true,
domain: process.env.COOKIE_DOMAIN || "localhost",
},
},
callbackUrl: {
name: `__Secure-next-auth.callback-url`,
options: {
sameSite: "None",
path: "/",
secure: true,
domain: process.env.COOKIE_DOMAIN || "localhost",
},
},
csrfToken: {
name: `next-auth.csrf-token`,
options: {
httpOnly: true,
sameSite: "None",
path: "/",
secure: true,
domain: process.env.COOKIE_DOMAIN || "localhost",
},
},
}
: undefined,
}
export default NextAuth(authOptions)