|
|
@ -24,15 +24,19 @@ class ApplicationController < ActionController::Base
|
|
|
|
# 所有请求必须合法签名
|
|
|
|
# 所有请求必须合法签名
|
|
|
|
def check_sign
|
|
|
|
def check_sign
|
|
|
|
Rails.logger.info("66666 #{params}")
|
|
|
|
Rails.logger.info("66666 #{params}")
|
|
|
|
if params[:client_key].present?
|
|
|
|
suffix = request.url.split(".").last
|
|
|
|
randomcode = params[:randomcode]
|
|
|
|
suffix_arr = ["xls", "xlsx"] # excel文件先注释
|
|
|
|
tip_exception(501, "请求不合理") unless (Time.now.to_i - randomcode.to_i).between?(0,5)
|
|
|
|
unless suffix_arr.include?(suffix)
|
|
|
|
|
|
|
|
if params[:client_key].present?
|
|
|
|
sign = Digest::MD5.hexdigest("#{OPENKEY}#{randomcode}")
|
|
|
|
randomcode = params[:randomcode]
|
|
|
|
Rails.logger.info("2222 #{sign}")
|
|
|
|
tip_exception(501, "请求不合理") unless (Time.now.to_i - randomcode.to_i).between?(0,5)
|
|
|
|
tip_exception(501, "请求不合理") if sign != params[:client_key]
|
|
|
|
|
|
|
|
else
|
|
|
|
sign = Digest::MD5.hexdigest("#{OPENKEY}#{randomcode}")
|
|
|
|
tip_exception(501, "请求不合理")
|
|
|
|
Rails.logger.info("2222 #{sign}")
|
|
|
|
|
|
|
|
tip_exception(501, "请求不合理") if sign != params[:client_key]
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
tip_exception(501, "请求不合理")
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|