From 8f4ccb8443aa63dfd329288164e5037f4f624998 Mon Sep 17 00:00:00 2001 From: austinkelsay Date: Sun, 6 Oct 2024 15:46:33 -0500 Subject: [PATCH] Fix email provider --- src/pages/api/auth/[...nextauth].js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/pages/api/auth/[...nextauth].js b/src/pages/api/auth/[...nextauth].js index b8d91ba..66350e5 100644 --- a/src/pages/api/auth/[...nextauth].js +++ b/src/pages/api/auth/[...nextauth].js @@ -48,7 +48,7 @@ const authorize = async (pubkey) => { } else { // Create user if (profile) { - track('Nostr Signup', { pubkey: pubkey, method: "nostr" }); + track('Nostr Signup', { pubkey: pubkey }); const fields = await findKind0Fields(profile); const payload = { pubkey, username: fields.username, avatar: fields.avatar }; @@ -114,11 +114,18 @@ export const authOptions = { }, from: process.env.EMAIL_FROM, sendVerificationRequest: async ({ identifier, url, provider }) => { + // Track the email signup event track('Email Signup', { email: identifier }); - // Use the default sendVerificationRequest function or customize it - const { sendVerificationRequest } = require("next-auth/providers/email"); - await sendVerificationRequest({ identifier, url, provider }); + // Use nodemailer to send the email + const transport = nodemailer.createTransport(provider.server); + await transport.sendMail({ + to: identifier, + from: provider.from, + subject: `Sign in to ${new URL(url).host}`, + text: `Sign in to ${new URL(url).host}\n${url}\n\n`, + html: `

Sign in to ${new URL(url).host}

Sign in

`, + }); } }), ],