Fix email provider

This commit is contained in:
austinkelsay 2024-10-06 15:46:33 -05:00
parent d23e98f535
commit 8f4ccb8443

View File

@ -48,7 +48,7 @@ const authorize = async (pubkey) => {
} else { } else {
// Create user // Create user
if (profile) { if (profile) {
track('Nostr Signup', { pubkey: pubkey, method: "nostr" }); track('Nostr Signup', { pubkey: pubkey });
const fields = await findKind0Fields(profile); const fields = await findKind0Fields(profile);
const payload = { pubkey, username: fields.username, avatar: fields.avatar }; const payload = { pubkey, username: fields.username, avatar: fields.avatar };
@ -114,11 +114,18 @@ export const authOptions = {
}, },
from: process.env.EMAIL_FROM, from: process.env.EMAIL_FROM,
sendVerificationRequest: async ({ identifier, url, provider }) => { sendVerificationRequest: async ({ identifier, url, provider }) => {
// Track the email signup event
track('Email Signup', { email: identifier }); track('Email Signup', { email: identifier });
// Use the default sendVerificationRequest function or customize it // Use nodemailer to send the email
const { sendVerificationRequest } = require("next-auth/providers/email"); const transport = nodemailer.createTransport(provider.server);
await sendVerificationRequest({ identifier, url, provider }); 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: `<p>Sign in to <strong>${new URL(url).host}</strong></p><p><a href="${url}">Sign in</a></p>`,
});
} }
}), }),
], ],