check for user email in support request

This commit is contained in:
miloschwartz
2025-10-27 21:56:22 -07:00
parent 8b4722b1c9
commit 772bda69f9

View File

@@ -48,11 +48,20 @@ export async function sendSupportEmail(
const { body, subject } = parsedBody.data; const { body, subject } = parsedBody.data;
const user = req.user!; const user = req.user!;
if (!user?.email) {
return next(
createHttpError(
HttpCode.BAD_REQUEST,
"User does not have an email associated with their account"
)
);
}
try { try {
await sendEmail( await sendEmail(
SupportEmail({ SupportEmail({
username: user.username, username: user.username,
email: user.email || "Unknown", email: user.email,
subject, subject,
body body
}), }),