fix(security): use server-configured PET notification recipient
This commit is contained in:
@@ -15,7 +15,6 @@ const allowedSubjects = [
|
||||
];
|
||||
|
||||
const allowedFields = new Set([
|
||||
"petEmail",
|
||||
"contactEmail",
|
||||
"contactSubject",
|
||||
"contactbody",
|
||||
@@ -120,22 +119,22 @@ export default async function ApiProxy(req, res) {
|
||||
);
|
||||
}
|
||||
|
||||
const petEmail = sanitizeString(requestBody.petEmail);
|
||||
const petEmail = sanitizeString(process.env.PETEMAIL);
|
||||
const contactEmail = sanitizeString(requestBody.contactEmail);
|
||||
const contactSubject = sanitizeString(requestBody.contactSubject);
|
||||
const contactBody = requestBody.contactbody;
|
||||
|
||||
if (
|
||||
typeof requestBody.petEmail !== "string" ||
|
||||
typeof process.env.PETEMAIL !== "string" ||
|
||||
!isNonEmptyString(petEmail) ||
|
||||
petEmail.length > 200 ||
|
||||
!emailRegex.test(petEmail)
|
||||
) {
|
||||
return validationError(
|
||||
res,
|
||||
"INVALID_PET_EMAIL",
|
||||
"petEmail must be a valid email address of 200 characters or fewer"
|
||||
);
|
||||
return respondError(res, {
|
||||
status: 500,
|
||||
code: "PET_RECIPIENT_NOT_CONFIGURED",
|
||||
message: "PET notification recipient is not configured"
|
||||
});
|
||||
}
|
||||
|
||||
if (
|
||||
|
||||
+3
-17
@@ -21,7 +21,6 @@ import {
|
||||
sendContactUsConfirmation,
|
||||
sendContactUsPETNotification
|
||||
} from "../actions/services/notifyDirectService";
|
||||
import { wrapper } from "../store/store";
|
||||
|
||||
import { useState } from "react";
|
||||
|
||||
@@ -322,7 +321,7 @@ let ContactUs = (props) => {
|
||||
sendContactEmail(formValues);
|
||||
createCRMTask(formValues);
|
||||
formValues.typeOfContact == "plq" &&
|
||||
sendPETEmail(formValues, props.petEmail);
|
||||
sendPETEmail(formValues);
|
||||
console.log("Form submitted:", formValues);
|
||||
};
|
||||
|
||||
@@ -350,11 +349,9 @@ let ContactUs = (props) => {
|
||||
}
|
||||
};
|
||||
|
||||
const sendPETEmail = async (formValues, petEmail) => {
|
||||
console.log(petEmail);
|
||||
|
||||
const sendPETEmail = async (formValues) => {
|
||||
try {
|
||||
const res = await sendContactUsPETNotification(formValues, petEmail);
|
||||
const res = await sendContactUsPETNotification(formValues);
|
||||
|
||||
console.log("Email sent successfully.");
|
||||
setFormSubmitted(true);
|
||||
@@ -519,17 +516,6 @@ const mapStateToProps = (state) => {
|
||||
};
|
||||
};
|
||||
|
||||
export const getServerSideProps = wrapper.getServerSideProps(
|
||||
(store) => async (ctx) => {
|
||||
const { req, locale } = ctx;
|
||||
return {
|
||||
props: {
|
||||
petEmail: process.env.PETEMAIL
|
||||
}
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
|
||||
@@ -21,7 +21,6 @@ import {
|
||||
sendContactUsConfirmation,
|
||||
sendContactUsPETNotification
|
||||
} from "../../actions/services/notifyDirectService";
|
||||
import { wrapper } from "../../store/store";
|
||||
|
||||
import { useState } from "react";
|
||||
|
||||
@@ -322,7 +321,7 @@ let ContactUs = (props) => {
|
||||
sendContactEmail(formValues);
|
||||
createCRMTask(formValues);
|
||||
formValues.typeOfContact == "plq" &&
|
||||
sendPETEmail(formValues, props.petEmail);
|
||||
sendPETEmail(formValues);
|
||||
console.log("Form submitted:", formValues);
|
||||
};
|
||||
|
||||
@@ -350,11 +349,9 @@ let ContactUs = (props) => {
|
||||
}
|
||||
};
|
||||
|
||||
const sendPETEmail = async (formValues, petEmail) => {
|
||||
console.log(petEmail);
|
||||
|
||||
const sendPETEmail = async (formValues) => {
|
||||
try {
|
||||
const res = await sendContactUsPETNotification(formValues, petEmail);
|
||||
const res = await sendContactUsPETNotification(formValues);
|
||||
|
||||
console.log("Email sent successfully.");
|
||||
setFormSubmitted(true);
|
||||
@@ -520,17 +517,6 @@ const mapStateToProps = (state) => {
|
||||
};
|
||||
};
|
||||
|
||||
export const getServerSideProps = wrapper.getServerSideProps(
|
||||
(store) => async (ctx) => {
|
||||
const { req, locale } = ctx;
|
||||
return {
|
||||
props: {
|
||||
petEmail: process.env.PETEMAIL
|
||||
}
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
|
||||
Reference in New Issue
Block a user