finalized password reset + code refactoring

This commit is contained in:
daniel31x13
2024-05-20 19:23:11 -04:00
parent 73dda21573
commit 329019b34e
12 changed files with 239 additions and 118 deletions
+14 -6
View File
@@ -1,12 +1,21 @@
import { readFileSync } from "fs";
import { SendVerificationRequestParams } from "next-auth/providers";
import path from "path";
import Handlebars from "handlebars";
import transporter from "./transporter";
export default async function sendVerificationRequest(
params: SendVerificationRequestParams
) {
type Params = {
identifier: string;
url: string;
from: string;
token: string;
};
export default async function sendVerificationRequest({
identifier,
url,
from,
token,
}: Params) {
const emailsDir = path.resolve(process.cwd(), "templates");
const templateFile = readFileSync(
@@ -16,13 +25,12 @@ export default async function sendVerificationRequest(
const emailTemplate = Handlebars.compile(templateFile);
const { identifier, url, provider, token } = params;
const { host } = new URL(url);
const result = await transporter.sendMail({
to: identifier,
from: {
name: "Linkwarden",
address: provider.from as string,
address: from as string,
},
subject: `Please verify your email address`,
text: text({ url, host }),