🐛 (auth) Fix email magic link pointing to internal auth URL
Closes #403
This commit is contained in:
@@ -1,14 +1,18 @@
|
|||||||
import { EmailConfig } from 'next-auth/providers/email'
|
|
||||||
import { sendMagicLinkEmail } from '@typebot.io/emails'
|
import { sendMagicLinkEmail } from '@typebot.io/emails'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
identifier: string
|
identifier: string
|
||||||
url: string
|
token: string
|
||||||
provider: Partial<Omit<EmailConfig, 'options'>>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const sendVerificationRequest = async ({ identifier, url }: Props) => {
|
export const sendVerificationRequest = async ({ identifier, token }: Props) => {
|
||||||
try {
|
try {
|
||||||
|
const url = `${
|
||||||
|
process.env.NEXTAUTH_URL
|
||||||
|
}/api/auth/callback/email?${new URLSearchParams({
|
||||||
|
email: identifier,
|
||||||
|
token,
|
||||||
|
}).toString()}`
|
||||||
await sendMagicLinkEmail({ url, to: identifier })
|
await sendMagicLinkEmail({ url, to: identifier })
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw new Error(`Email(s) could not be sent`)
|
throw new Error(`Email(s) could not be sent`)
|
||||||
|
|||||||
Reference in New Issue
Block a user