mirror of
https://github.com/Infisical/infisical.git
synced 2026-01-11 00:17:59 -05:00
feat: adds account deletion confirmation email
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import { Heading, Section, Text } from "@react-email/components";
|
||||
import React from "react";
|
||||
|
||||
import { BaseEmailWrapper, BaseEmailWrapperProps } from "./BaseEmailWrapper";
|
||||
|
||||
interface AccountDeletionConfirmationTemplateProps
|
||||
extends Omit<BaseEmailWrapperProps, "title" | "preview" | "children"> {
|
||||
email: string;
|
||||
}
|
||||
|
||||
export const AccountDeletionConfirmationTemplate = ({ email, siteUrl }: AccountDeletionConfirmationTemplateProps) => {
|
||||
return (
|
||||
<BaseEmailWrapper
|
||||
title="Your Infisical Account Has Been Deleted"
|
||||
preview="Confirmation that your account and associated data have been deleted."
|
||||
siteUrl={siteUrl}
|
||||
>
|
||||
<Heading className="text-black text-[18px] leading-[28px] text-center font-normal p-0 mx-0">
|
||||
Account Deleted
|
||||
</Heading>
|
||||
<Section className="px-[24px] mt-[20px] pt-[12px] pb-[8px] border border-solid border-gray-200 rounded-md bg-gray-50">
|
||||
<Text className="text-[14px]">
|
||||
This email confirms that your Infisical account <strong>{email}</strong> has been deleted, including all
|
||||
associated data.
|
||||
</Text>
|
||||
</Section>
|
||||
</BaseEmailWrapper>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccountDeletionConfirmationTemplate;
|
||||
|
||||
AccountDeletionConfirmationTemplate.PreviewProps = {
|
||||
email: "test@infisical.com",
|
||||
siteUrl: "https://infisical.com"
|
||||
} as AccountDeletionConfirmationTemplateProps;
|
||||
@@ -30,3 +30,4 @@ export * from "./SecretSyncFailedTemplate";
|
||||
export * from "./ServiceTokenExpiryNoticeTemplate";
|
||||
export * from "./SignupEmailVerificationTemplate";
|
||||
export * from "./UnlockAccountTemplate";
|
||||
export * from "./AccountDeletionConfirmationTemplate";
|
||||
|
||||
@@ -9,6 +9,7 @@ import { logger } from "@app/lib/logger";
|
||||
import {
|
||||
AccessApprovalRequestTemplate,
|
||||
AccessApprovalRequestUpdatedTemplate,
|
||||
AccountDeletionConfirmationTemplate,
|
||||
EmailMfaTemplate,
|
||||
EmailVerificationTemplate,
|
||||
ExternalImportFailedTemplate,
|
||||
@@ -83,7 +84,8 @@ export enum SmtpTemplates {
|
||||
OrgAdminBreakglassAccess = "orgAdminBreakglassAccess",
|
||||
ServiceTokenExpired = "serviceTokenExpired",
|
||||
SecretScanningV2ScanFailed = "secretScanningV2ScanFailed",
|
||||
SecretScanningV2SecretsDetected = "secretScanningV2SecretsDetected"
|
||||
SecretScanningV2SecretsDetected = "secretScanningV2SecretsDetected",
|
||||
AccountDeletionConfirmation = "accountDeletionConfirmation"
|
||||
}
|
||||
|
||||
export enum SmtpHost {
|
||||
@@ -128,7 +130,8 @@ const EmailTemplateMap: Record<SmtpTemplates, React.FC<any>> = {
|
||||
[SmtpTemplates.SetupPassword]: PasswordSetupTemplate,
|
||||
[SmtpTemplates.PkiExpirationAlert]: PkiExpirationAlertTemplate,
|
||||
[SmtpTemplates.SecretScanningV2ScanFailed]: SecretScanningScanFailedTemplate,
|
||||
[SmtpTemplates.SecretScanningV2SecretsDetected]: SecretScanningSecretsDetectedTemplate
|
||||
[SmtpTemplates.SecretScanningV2SecretsDetected]: SecretScanningSecretsDetectedTemplate,
|
||||
[SmtpTemplates.AccountDeletionConfirmation]: AccountDeletionConfirmationTemplate
|
||||
};
|
||||
|
||||
export const smtpServiceFactory = (cfg: TSmtpConfig) => {
|
||||
|
||||
@@ -347,6 +347,19 @@ export const userServiceFactory = ({
|
||||
|
||||
const deleteUser = async (userId: string) => {
|
||||
const user = await userDAL.deleteById(userId);
|
||||
|
||||
if (user?.email) {
|
||||
// Send email to user to confirm account deletion
|
||||
await smtpService.sendMail({
|
||||
template: SmtpTemplates.AccountDeletionConfirmation,
|
||||
subjectLine: "Your Infisical account has been deleted",
|
||||
recipients: [user.email],
|
||||
substitutions: {
|
||||
email: user.email
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return user;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user