Skip to main content

verify_acp_org_access

Function verify_acp_org_access 

Source
pub async fn verify_acp_org_access(
    user: &AuthenticatedUser,
    acp_id: Uuid,
    acp_use_cases: &AcpUseCases,
) -> Result<(), AppError>
Expand description

Hotfix #603 — résout building.acp_id -> acp.organization_id et applique l’isolation multi-tenant sur les GET-by-id (building, budget, expense, meeting, resolution, unit, work_report).

Après #602 (Building.organization_id -> acp_id), BuildingResponseDto ne porte plus organization_id ; les 7 handlers ci-dessus ont perdu leur user.verify_org_access(...). Ce helper recâble la chaîne en lookup ACP.

Sémantique :

  • SuperAdmin : toujours autorisé (bypass).
  • Sinon : acp.organization_id MUST == user.organization_id. Sinon AppError::AcpNotInScope (HTTP 403 via ResponseError).
  • ACP introuvable OU acp.organization_id IS NULL (auto-gérée) : refuse pour non-superadmin (conservateur — gouvernance ACP auto-gérée en story 4.x).