Harden authentication, tenant isolation and security boundaries
This commit is contained in:
+15
-9
@@ -20,11 +20,11 @@ export function getAppEmailConfigError() {
|
||||
return null;
|
||||
}
|
||||
if (!process.env.RESEND_API_KEY) {
|
||||
return "RESEND_API_KEY ist nicht konfiguriert.";
|
||||
return "E-Mail-Versand ist derzeit nicht verfügbar.";
|
||||
}
|
||||
|
||||
if (!process.env.EMAIL_FROM) {
|
||||
return "EMAIL_FROM ist nicht konfiguriert.";
|
||||
return "E-Mail-Versand ist derzeit nicht verfügbar.";
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -37,6 +37,15 @@ export async function sendAppEmail({
|
||||
from = process.env.EMAIL_FROM,
|
||||
replyTo,
|
||||
}: SendAppEmailInput): Promise<SendAppEmailResult> {
|
||||
if (Array.isArray(to)) {
|
||||
let id: string | undefined;
|
||||
for (const recipient of new Set(to)) {
|
||||
const result = await sendAppEmail({ to: recipient, subject, react, from, replyTo });
|
||||
if (!result.success) return result;
|
||||
id = result.id;
|
||||
}
|
||||
return { success: true, id };
|
||||
}
|
||||
if (!process.env.RESEND_API_KEY) {
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
console.log("\n✉️ [DEV EMAIL SIMULATION]");
|
||||
@@ -50,14 +59,14 @@ export async function sendAppEmail({
|
||||
}
|
||||
return {
|
||||
success: false,
|
||||
error: "RESEND_API_KEY ist nicht konfiguriert.",
|
||||
error: "E-Mail-Versand ist derzeit nicht verfügbar.",
|
||||
};
|
||||
}
|
||||
|
||||
if (!from) {
|
||||
return {
|
||||
success: false,
|
||||
error: "EMAIL_FROM ist nicht konfiguriert.",
|
||||
error: "E-Mail-Versand ist derzeit nicht verfügbar.",
|
||||
};
|
||||
}
|
||||
|
||||
@@ -75,7 +84,7 @@ export async function sendAppEmail({
|
||||
console.error("Resend konnte die E-Mail nicht versenden:", error);
|
||||
return {
|
||||
success: false,
|
||||
error: error.message ?? "E-Mail-Versand fehlgeschlagen.",
|
||||
error: "E-Mail-Versand fehlgeschlagen.",
|
||||
};
|
||||
}
|
||||
|
||||
@@ -84,10 +93,7 @@ export async function sendAppEmail({
|
||||
console.error("Unerwarteter Fehler beim E-Mail-Versand:", error);
|
||||
return {
|
||||
success: false,
|
||||
error:
|
||||
error instanceof Error
|
||||
? error.message
|
||||
: "Unerwarteter Fehler beim E-Mail-Versand.",
|
||||
error: "E-Mail-Versand fehlgeschlagen.",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user