Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
use email for notification
Thiago Araujo da Silva42c364fce8d5
diff --git a/backend/src/services/account-recovery/account-recovery-service.ts b/backend/src/services/account-recovery/account-recovery-service.tsindex 4098dc574a..239236aea2 100644--- a/backend/src/services/account-recovery/account-recovery-service.ts+++ b/backend/src/services/account-recovery/account-recovery-service.ts@@ -32,18 +32,19 @@ export const accountRecoveryServiceFactory = ({/** Account recovery flow via email. Step 1: send recovery email*/- const sendRecoveryEmail = async (unsanitizedEmail: string) => {+ const sendRecoveryEmail = async (unsanitizedUsername: string) => {const sendEmail = async () => {- const email = sanitizeEmail(unsanitizedEmail);- const user = await userDAL.findOne({ username: email });+ const username = sanitizeEmail(unsanitizedUsername);+ const user = await userDAL.findOne({ username });if (!user) throw new BadRequestError({ message: "Failed to find user data" });if (user && user.isAccepted) {const cfg = getConfig();+ const recipient = user.email ?? user.username;const hasEmailAuth = user.authMethods?.includes(AuthMethod.EMAIL);const substitutions: Record<string, unknown> = {- email,+ username: user.username,isCloud: cfg.isCloud,siteUrl: cfg.SITE_URL || "",hasEmailAuth,@@ -71,7 +72,7 @@ export const accountRecoveryServiceFactory = ({substitutions.token = token;await smtpService.sendMail({template: SmtpTemplates.ResetPassword,- recipients: [email],+ recipients: [recipient],subjectLine: "Infisical account recovery",substitutions});@@ -85,10 +86,10 @@ export const accountRecoveryServiceFactory = ({/** Account recovery flow via email. Step 2: verify the token and inject a temp token to reset password*/- const verifyRecoveryEmail = async (unsanitizedEmail: string, code: string) => {+ const verifyRecoveryEmail = async (unsanitizedUsername: string, code: string) => {const cfg = getConfig();- const email = sanitizeEmail(unsanitizedEmail);- const user = await userDAL.findOne({ username: email });+ const username = sanitizeEmail(unsanitizedUsername);+ const user = await userDAL.findOne({ username });// Use a dummy userId when there's no valid user.const shouldReject = !user || (user && !user.isAccepted);diff --git a/backend/src/services/smtp/emails/PasswordResetTemplate.tsx b/backend/src/services/smtp/emails/PasswordResetTemplate.tsxindex 37ef565f88..05f4359f24 100644--- a/backend/src/services/smtp/emails/PasswordResetTemplate.tsx+++ b/backend/src/services/smtp/emails/PasswordResetTemplate.tsx@@ -5,7 +5,7 @@ import { BaseButton } from "./BaseButton";import { BaseEmailWrapper, BaseEmailWrapperProps } from "./BaseEmailWrapper";interface PasswordResetTemplateProps extends Omit<BaseEmailWrapperProps, "title" | "preview" | "children"> {- email: string;+ username: string;callback_url: string;token: string;isCloud: boolean;@@ -14,7 +14,7 @@ interface PasswordResetTemplateProps extends Omit<BaseEmailWrapperProps, "title"}export const PasswordResetTemplate = ({- email,+ username,siteUrl,callback_url,token,@@ -66,7 +66,9 @@ export const PasswordResetTemplate = ({</Text></Section><Section className="text-center">- <BaseButton href={`${callback_url}?token=${token}&to=${encodeURIComponent(email)}`}>Restore Access</BaseButton>+ <BaseButton href={`${callback_url}?token=${token}&to=${encodeURIComponent(username)}`}>+ Restore Access+ </BaseButton></Section></BaseEmailWrapper>);@@ -75,7 +77,7 @@ export const PasswordResetTemplate = ({export default PasswordResetTemplate;PasswordResetTemplate.PreviewProps = {- email: "[email protected]",+ username: "[email protected]",callback_url: "https://app.infisical.com",isCloud: true,token: "preview-token",