Dashboard-API: Center-Scoping (Listen)
List endpoints use the same layer:
- Explicit Center:
?centerId=<uuid>→ for logged-in usersassertCenterAccess; without login, restriction to this center only (e.g., kiosk/proxy with?centerId=). - No
centerIdin the URL: Session required;buildCenterFilter(session)→params.centerIds. pickCenterWhereFragment/createStandardWhereClauseinlib/api/utils.tsmap to Prisma:centerIdorcenterId: { in: [...] }. EmptycenterIds→ no matches.
Server Helper: mergeSessionCenterScopeIntoListParams in apps/dashboard/src/lib/api/list-route-center-scope.ts — call before findMany (including GET /api/events, /api/jobs, /api/services, Hot-Picks, /api/content/metrics, /api/content/recent). Manual Prisma routes use pickCenterWhereFragment for the center fragment of the where clause.
Notes
- The placeholder
allshould not be in the query.centerIdQueryParaminapps/dashboard/src/lib/center-query.ts;extractQueryParamsdiscards?centerId=all. GET /api/offerscontinues to build the session filter directly into Prisma (same semantics).- News/Shops:
createStandardWhereClause(usespickCenterWhereFragment).
This keeps dashboard lists consistent when changing centers or "All Centers" (Super Admin).
Related: Audit: Namespace /api/content/* — which routes still have CORS/without session and who calls them.
Nutzungsstatistik: Seitenaufrufe werden anonymisiert erfasst. Im Umami-Dashboard nach diesem Pfad filtern: /en/developer-guide/dashboard-api-center-scoping