feat: ✨ Add collaboration
This commit is contained in:
27
apps/builder/services/api/emails.ts
Normal file
27
apps/builder/services/api/emails.ts
Normal file
@ -0,0 +1,27 @@
|
||||
import { createTransport } from 'nodemailer'
|
||||
|
||||
export const sendEmailNotification = ({
|
||||
to,
|
||||
subject,
|
||||
content,
|
||||
}: {
|
||||
to: string
|
||||
subject: string
|
||||
content: string
|
||||
}) => {
|
||||
const transporter = createTransport({
|
||||
host: process.env.AUTH_EMAIL_SERVER_HOST,
|
||||
port: Number(process.env.AUTH_EMAIL_SERVER_PORT),
|
||||
auth: {
|
||||
user: process.env.AUTH_EMAIL_SERVER_USER,
|
||||
pass: process.env.AUTH_EMAIL_SERVER_PASSWORD,
|
||||
},
|
||||
})
|
||||
|
||||
return transporter.sendMail({
|
||||
from: `"${process.env.AUTH_EMAIL_FROM_NAME}" <${process.env.AUTH_EMAIL_FROM_EMAIL}>`,
|
||||
to,
|
||||
subject,
|
||||
html: content,
|
||||
})
|
||||
}
|
10
apps/builder/services/api/utils.ts
Normal file
10
apps/builder/services/api/utils.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import { User } from 'db'
|
||||
import { NextApiRequest } from 'next'
|
||||
import { getSession } from 'next-auth/react'
|
||||
|
||||
export const getAuthenticatedUser = async (
|
||||
req: NextApiRequest
|
||||
): Promise<User | undefined> => {
|
||||
const session = await getSession({ req })
|
||||
return session?.user as User | undefined
|
||||
}
|
Reference in New Issue
Block a user