Commit 7a6189a9 authored by Antony Le Courtes's avatar Antony Le Courtes
Browse files

Renforcement sécurité sur téléchargement fichiers liés au contrat de l'intervenant

parent 25c5170a
Loading
Loading
Loading
Loading
Loading
+9 −3
Changes for module/Contrat/src/Controller/ContratController.php: 9 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -515,16 +515,22 @@ class ContratController extends AbstractController
    public function telechargerFichierAction()
    {
        $contrat = $this->getEvent()->getParam('contrat');
        /* @var $contrat Contrat */
        $fichierDemandee = $this->getEvent()->getParam('fichier');

        if (!$this->isAllowed($contrat, Privileges::CONTRAT_VISUALISATION)) {
            throw new UnAuthorizedException('Vous n\'avez pas de droit de télécharger ce fichier');
        }

        $fichier = $this->getEvent()->getParam('fichier');

        $fichiersContrat = $contrat->getFichier();
        foreach ($fichiersContrat as $fichier) {
            if ($fichier->getId() == $fichierDemandee->getId()) {
                $this->uploader()->download($fichier);
            }
        }

        throw new \Exception('Le fichier n\'existe pas ou bien il appartient à un autre intervenant');

    }