-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauth.ts
More file actions
26 lines (25 loc) · 685 Bytes
/
Copy pathauth.ts
File metadata and controls
26 lines (25 loc) · 685 Bytes
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
import NextAuth from "next-auth";
import { PrismaAdapter } from "@auth/prisma-adapter";
import GitHub from "next-auth/providers/github";
import { db } from "./src/server/db";
export const { handlers, signIn, signOut, auth } = NextAuth({
adapter: PrismaAdapter(db),
providers: [GitHub],
pages: {
signIn: "/sign-in",
},
callbacks: {
async signIn({ user }) {
const dbUser = await db.user.findUnique({
where: { id: user.id },
});
if (dbUser && dbUser.emailVerified === null) {
await db.user.update({
where: { id: user.id },
data: { emailVerified: new Date() },
});
}
return true;
},
},
});