From 0473c9fc2e58b73ff0aa0dcf886904e5f12fb83a Mon Sep 17 00:00:00 2001 From: f Date: Sat, 10 Oct 2020 14:14:02 -0300 Subject: [PATCH] =?UTF-8?q?sitios=20privados=20en=20producci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/private_controller.rb | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/app/controllers/private_controller.rb b/app/controllers/private_controller.rb index 36a7a78..bb4d782 100644 --- a/app/controllers/private_controller.rb +++ b/app/controllers/private_controller.rb @@ -19,11 +19,9 @@ class PrivateController < ApplicationController return end - if deploy_private && File.exist?(path) - send_file path, disposition: 'inline' - else - head :not_found - end + raise PageNotFound if deploy_private && File.exist?(path) + + send_file path, disposition: 'inline' end private @@ -47,15 +45,9 @@ class PrivateController < ApplicationController # Devuelve la ruta completa del archivo def path - return @path if @path - - @path = Pathname.new(File.join(deploy_private.destination, file)).realpath.to_s - - raise Errno::ENOENT unless @path.starts_with? deploy_private.destination - - @path + @path ||= Pathname.new(File.join(deploy_private.destination, file)).realpath.to_s rescue Errno::ENOENT - not_found_path + site_not_found_path end # Devuelve la ruta del archivo, limpieza copiada desde Jekyll @@ -76,12 +68,6 @@ class PrivateController < ApplicationController end # Devuelve una página 404.html - def not_found_path - return site_not_found_path if File.exist? site_not_found_path - - raise PageNotFound - end - def site_not_found_path @site_not_found_path ||= File.join(deploy_private.destination, '404.html') end