From 785a09b326a5c5919d6d93d724efd949ecf532df Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Thu, 19 Dec 2019 18:15:37 +0100 Subject: [PATCH] Use service_url instead of blob_url on secure attachments --- app/controllers/instructeurs/dossiers_controller.rb | 2 +- app/controllers/users/dossiers_controller.rb | 2 +- app/graphql/types/file.rb | 2 +- app/models/champs/piece_justificative_champ.rb | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/instructeurs/dossiers_controller.rb b/app/controllers/instructeurs/dossiers_controller.rb index caa08f48a..06c6e5ac4 100644 --- a/app/controllers/instructeurs/dossiers_controller.rb +++ b/app/controllers/instructeurs/dossiers_controller.rb @@ -15,7 +15,7 @@ module Instructeurs def attestation if dossier.attestation.pdf.attached? - redirect_to url_for(dossier.attestation.pdf) + redirect_to dossier.attestation.pdf.service_url end end diff --git a/app/controllers/users/dossiers_controller.rb b/app/controllers/users/dossiers_controller.rb index 2baaab0fe..df9204e89 100644 --- a/app/controllers/users/dossiers_controller.rb +++ b/app/controllers/users/dossiers_controller.rb @@ -49,7 +49,7 @@ module Users def attestation if dossier.attestation&.pdf&.attached? - redirect_to url_for(dossier.attestation.pdf) + redirect_to dossier.attestation.pdf.service_url else flash.notice = "L'attestation n'est plus disponible sur ce dossier." redirect_to dossier_path(dossier) diff --git a/app/graphql/types/file.rb b/app/graphql/types/file.rb index 58b79d083..6f30cd9a9 100644 --- a/app/graphql/types/file.rb +++ b/app/graphql/types/file.rb @@ -7,7 +7,7 @@ module Types field :content_type, String, null: false def url - Rails.application.routes.url_helpers.url_for(object) + object.service_url end end end diff --git a/app/models/champs/piece_justificative_champ.rb b/app/models/champs/piece_justificative_champ.rb index 27bda0eb8..35403deb6 100644 --- a/app/models/champs/piece_justificative_champ.rb +++ b/app/models/champs/piece_justificative_champ.rb @@ -48,7 +48,7 @@ class Champs::PieceJustificativeChamp < Champ def for_api if piece_justificative_file.attached? && (piece_justificative_file.virus_scanner.safe? || piece_justificative_file.virus_scanner.pending?) - Rails.application.routes.url_helpers.url_for(piece_justificative_file) + piece_justificative_file.service_url end end end