Don't authorize! until we know the digital file exists
This commit is contained in:
1 parent
f8da0db2b7
commit
cdbc636e79
1 file changed
+12
-3
@@ -1,16 +1,25 @@
|
|||||||
module Spree
|
module Spree
|
||||||
class DigitalsController < Spree::BaseController
|
class DigitalsController < Spree::BaseController
|
||||||
|
|
||||||
ssl_required :show
|
ssl_required :show
|
||||||
|
|
||||||
def show
|
def show
|
||||||
link = DigitalLink.find_by_secret(params[:secret])
|
link = DigitalLink.find_by_secret(params[:secret])
|
||||||
|
|
||||||
if link.present? and link.digital.attachment.present?
|
if link.present? and link.digital.attachment.present?
|
||||||
attachment = link.digital.attachment
|
attachment = link.digital.attachment
|
||||||
if link.authorize! and File.file?(attachment.path)
|
|
||||||
send_file attachment.path, :filename => attachment.original_filename, :type => attachment.content_type and return
|
# don't authorize the link unless the file exists
|
||||||
|
# the logger error will help track down customer issues easier
|
||||||
|
|
||||||
|
if File.file?(attachment.path)
|
||||||
|
if link.authorize!
|
||||||
|
send_file attachment.path, :filename => attachment.original_filename, :type => attachment.content_type and return
|
||||||
|
end
|
||||||
|
else
|
||||||
|
Rails.logger.error "Missing Digital Item: #{attachment.path}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
render :unauthorized
|
render :unauthorized
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user