generated from imperial/impaas-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
auth.ts
32 lines (29 loc) · 991 Bytes
/
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
import authConfig from "./auth.config"
import { PrismaAdapter } from "@auth/prisma-adapter"
import { PrismaClient } from "@prisma/client"
import NextAuth from "next-auth"
import Nodemailer from "next-auth/providers/nodemailer"
import { sendVerificationRequest } from "./emails/sender"
const prisma = new PrismaClient()
export const { handlers, auth, signIn, signOut } = NextAuth({
adapter: PrismaAdapter(prisma),
session: { strategy: "jwt" },
...authConfig,
providers: [
...authConfig.providers,
// NOTE: If placed in the other file, the middleware will not work
// as NodeMailer doesn't work in the edge
Nodemailer({
server: {
host: process.env.EMAIL_SERVER_HOST,
port: parseInt(process.env.EMAIL_SERVER_PORT ?? "587", 10),
auth: {
user: process.env.EMAIL_SERVER_USER,
pass: process.env.EMAIL_SERVER_PASSWORD,
},
},
from: process.env.EMAIL_FROM,
sendVerificationRequest,
}),
],
})