feat: custom login email

This commit is contained in:
Henry
2024-01-09 13:48:53 +00:00
parent 4f909b02f0
commit fac4cc97e3
145 changed files with 34926 additions and 2 deletions

View File

@@ -1,3 +1,6 @@
import { render } from '@react-email/render';
import { MagicLinkEmail } from "~/email/emails/magic-link";
import { DrizzleAdapter } from "@auth/drizzle-adapter";
import NextAuth, { type DefaultSession } from "next-auth";
@@ -25,6 +28,8 @@ declare module "next-auth" {
// }
}
export const {
handlers: { GET, POST },
auth,
@@ -57,6 +62,7 @@ export const {
name: 'Email',
options: {},
async sendVerificationRequest({ identifier: email, url }) {
const magicLinkEmail = MagicLinkEmail({ loginUrl: url });
await fetch(process.env.EMAIL_URL ?? '', {
method: "POST",
headers: {
@@ -67,7 +73,7 @@ export const {
from: process.env.EMAIL_FROM,
to: [email],
subject: 'Login via email',
html: `<strong>${url}</strong>`,
html: render(magicLinkEmail),
}),
})