diff --git a/backend/src/controllers/contract.controller.ts b/backend/src/controllers/contract.controller.ts index be91a850..79787f29 100644 --- a/backend/src/controllers/contract.controller.ts +++ b/backend/src/controllers/contract.controller.ts @@ -96,17 +96,20 @@ export async function getContracts(req: AuthRequest, res: Response): Promise { } } - const page = parseInt((req.query.page as string) || '1') || 1; - const limit = Math.min(parseInt((req.query.limit as string) || '50') || 50, 200); + const page = Math.max(parseInt((req.query.page as string) || '1') || 1, 1); + const limit = Math.min(Math.max(parseInt((req.query.limit as string) || '50') || 50, 1), 200); const search = typeof req.query.search === 'string' ? req.query.search : undefined; const result = await creditNoteService.getAllCreditNotes({ customerIds, page, limit, search }); diff --git a/backend/src/services/contract.service.ts b/backend/src/services/contract.service.ts index f2758f07..7ccd831b 100644 --- a/backend/src/services/contract.service.ts +++ b/backend/src/services/contract.service.ts @@ -21,8 +21,11 @@ export async function getAllContracts(filters: ContractFilters) { const where: Record = {}; - // Entweder einzelne customerId ODER Liste von customerIds (für Kundenportal) - if (customerIds && customerIds.length > 0) { + // Entweder Liste von customerIds (Kundenportal, fail-closed) ODER einzelne + // customerId (Staff-Filter). Fail-closed (Pentest R145): ist customerIds + // gesetzt – auch als LEERES Array – wird strikt darauf gefiltert (`IN ()` + // → 0 Treffer). Nur `undefined` (Staff) überspringt den Filter. + if (customerIds) { where.customerId = { in: customerIds }; } else if (customerId) { where.customerId = customerId;