22 lines
549 B
TypeScript
22 lines
549 B
TypeScript
import { sendMagicLinkEmail } from '@typebot.io/emails'
|
|
|
|
type Props = {
|
|
identifier: string
|
|
token: string
|
|
}
|
|
|
|
export const sendVerificationRequest = async ({ identifier, token }: Props) => {
|
|
try {
|
|
const url = `${
|
|
process.env.NEXTAUTH_URL
|
|
}/api/auth/callback/email?${new URLSearchParams({
|
|
email: identifier,
|
|
token,
|
|
callbackUrl: `${process.env.NEXTAUTH_URL}/signin`,
|
|
}).toString()}`
|
|
await sendMagicLinkEmail({ url, to: identifier })
|
|
} catch (err) {
|
|
throw new Error(`Email(s) could not be sent`)
|
|
}
|
|
}
|