Kunde-E-Mail: Pflicht nur beim Anlegen, nicht beim Bearbeiten
Bestandskunden ohne E-Mail bleiben editierbar. Beim Anlegen ist E-Mail weiterhin Pflicht (Frontend required + Backend createCustomer). Die Domain-Pruefung (keine verwaltete Provider-Domain) greift unveraendert bei create UND update, falls eine E-Mail gesetzt wird. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -181,11 +181,9 @@ export async function updateCustomer(req: Request, res: Response): Promise<void>
|
||||
return;
|
||||
}
|
||||
const data: any = pickCustomerUpdate(req.body);
|
||||
// E-Mail ist Pflichtfeld – darf per Update nicht geleert werden.
|
||||
if ('email' in data && (!data.email || !String(data.email).trim())) {
|
||||
res.status(400).json({ success: false, error: 'E-Mail-Adresse ist ein Pflichtfeld.' } as ApiResponse);
|
||||
return;
|
||||
}
|
||||
// E-Mail ist nur beim ANLEGEN Pflicht – beim Bearbeiten darf ein
|
||||
// Bestandskunde ohne E-Mail bleiben (die Domain-Prüfung oben greift aber
|
||||
// weiterhin, falls doch eine gesetzt wird).
|
||||
|
||||
// Pentest 60.3 (MEDIUM, 2026-06-01): pickCustomerUpdate macht nur
|
||||
// stripHtml; CRLF und andere Control-Chars überlebten. Phone/Mobile
|
||||
@@ -214,8 +212,7 @@ export async function updateCustomer(req: Request, res: Response): Promise<void>
|
||||
data.birthDate = new Date(data.birthDate);
|
||||
}
|
||||
// Leere Strings in optionalen Feldern zu null konvertieren
|
||||
// 'email' NICHT nullable – ist Pflichtfeld (leer wird oben schon abgelehnt).
|
||||
const nullableFields = ['salutation', 'birthPlace', 'phone', 'mobile', 'companyName', 'taxNumber', 'businessRegistration', 'commercialRegister', 'commercialRegisterNumber', 'notes'];
|
||||
const nullableFields = ['salutation', 'birthPlace', 'phone', 'mobile', 'email', 'companyName', 'taxNumber', 'businessRegistration', 'commercialRegister', 'commercialRegisterNumber', 'notes'];
|
||||
for (const field of nullableFields) {
|
||||
if (data[field] === '') data[field] = null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user