2
0

🐛 (auth) Fix email magic link pointing to internal auth URL

Closes #403
This commit is contained in:
Baptiste Arnaud
2023-03-28 07:54:20 +02:00
parent 787ac50f90
commit 5e91f4d0ef

View File

@ -1,14 +1,18 @@
import { EmailConfig } from 'next-auth/providers/email'
import { sendMagicLinkEmail } from '@typebot.io/emails'
type Props = {
identifier: string
url: string
provider: Partial<Omit<EmailConfig, 'options'>>
token: string
}
export const sendVerificationRequest = async ({ identifier, url }: Props) => {
export const sendVerificationRequest = async ({ identifier, token }: Props) => {
try {
const url = `${
process.env.NEXTAUTH_URL
}/api/auth/callback/email?${new URLSearchParams({
email: identifier,
token,
}).toString()}`
await sendMagicLinkEmail({ url, to: identifier })
} catch (err) {
throw new Error(`Email(s) could not be sent`)