-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauth.ts
55 lines (50 loc) · 1.52 KB
/
auth.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
import NextAuth from 'next-auth';
import GoogleProvider from 'next-auth/providers/google';
// import prisma from './lib/prisma';
export const {
handlers: { GET, POST },
auth,
} = NextAuth({
providers: [
GoogleProvider({
clientId: process.env.GOOGLE_CLIENT_ID as string,
clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,
}),
],
// callbacks: {
// async signIn({ account, profile }) {
// if (account?.provider === 'google') {
// const existingUser = profile?.email
// ? await prisma.user.findUnique({ where: { email: profile.email } })
// : null;
// if (existingUser) {
// return true;
// }
// await prisma.user.create({
// data: {
// email: profile?.email as string,
// name: profile?.name as string,
// subscription: {
// create: {},
// },
// },
// }); // Create a new user with these details
// return true;
// }
// // TODO: handle other providers
// return false;
// },
// async session({ session, token }) {
// const dbUser = token.email
// ? await prisma.user.findUnique({
// where: { email: token.email },
// })
// : null;
// // eslint-disable-next-line no-param-reassign
// session.userId = dbUser?.id as string;
// return session;
// },
// },
// TODO: this wasnt in docs but seems to be required
secret: process.env.NEXT_AUTH_SECRET,
});