cal/packages/emails/templates/forgot-password-email.ts
Benny Joo ca78be011c
chore: [app-router-migration-1] migrate the pages in `settings/admin` to the app directory (#12561)
Co-authored-by: Dmytro Hryshyn <dev.dmytroh@gmail.com>
Co-authored-by: DmytroHryshyn <125881252+DmytroHryshyn@users.noreply.github.com>
Co-authored-by: zomars <zomars@me.com>
2023-12-01 13:07:26 -07:00

51 lines
1.6 KiB
TypeScript

import type { TFunction } from "next-i18next";
import { APP_NAME } from "@calcom/lib/constants";
import { renderEmail } from "../";
import BaseEmail from "./_base-email";
export type PasswordReset = {
language: TFunction;
user: {
name?: string | null;
email: string;
};
resetLink: string;
};
export default class ForgotPasswordEmail extends BaseEmail {
passwordEvent: PasswordReset;
constructor(passwordEvent: PasswordReset) {
super();
this.name = "SEND_PASSWORD_RESET_EMAIL";
this.passwordEvent = passwordEvent;
}
protected async getNodeMailerPayload(): Promise<Record<string, unknown>> {
return {
to: `${this.passwordEvent.user.name} <${this.passwordEvent.user.email}>`,
from: `${APP_NAME} <${this.getMailerOptions().from}>`,
subject: this.passwordEvent.language("reset_password_subject", {
appName: APP_NAME,
}),
html: await renderEmail("ForgotPasswordEmail", this.passwordEvent),
text: this.getTextBody(),
};
}
protected getTextBody(): string {
return `
${this.passwordEvent.language("reset_password_subject", { appName: APP_NAME })}
${this.passwordEvent.language("hi_user_name", { name: this.passwordEvent.user.name })},
${this.passwordEvent.language("someone_requested_password_reset")}
${this.passwordEvent.language("change_password")}: ${this.passwordEvent.resetLink}
${this.passwordEvent.language("password_reset_instructions")}
${this.passwordEvent.language("have_any_questions")} ${this.passwordEvent.language(
"contact_our_support_team"
)}
`.replace(/(<([^>]+)>)/gi, "");
}
}