From 40edd40ab70439020cdc7bf095354665f1af9103 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 30 Dec 2019 16:35:50 +0800 Subject: [PATCH 1/5] 1 --- app/controllers/admins/base_controller.rb | 1 + app/controllers/application_controller.rb | 1 + 2 files changed, 2 insertions(+) diff --git a/app/controllers/admins/base_controller.rb b/app/controllers/admins/base_controller.rb index f90c8a1ed..9a4a25013 100644 --- a/app/controllers/admins/base_controller.rb +++ b/app/controllers/admins/base_controller.rb @@ -10,6 +10,7 @@ class Admins::BaseController < ApplicationController before_action :require_login, :require_admin! after_action :rebind_event_if_ajax_render_partial + skip_before_action :check_sign private diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 634209570..3d1fd642e 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -27,6 +27,7 @@ class ApplicationController < ActionController::Base if params[:client_key].present? Rails.logger.info("111111 #{params[:client_key]}") Rails.logger.info("00000 #{params[:timestamp]}") + tip_exception(501, "请求超时") if Time.now - params[:timestamp].to_i > 5 timestamp = params[:timestamp] sign = Digest::MD5.hexdigest("#{OPENKEY}#{timestamp}") Rails.logger.info("2222 #{sign}") From 1d43efcdd1607897e76e199fcbb58f8b568aa6fb Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 30 Dec 2019 16:49:18 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E6=97=B6=E9=97=B4=E6=90=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 3d1fd642e..4daa3b45c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -27,7 +27,7 @@ class ApplicationController < ActionController::Base if params[:client_key].present? Rails.logger.info("111111 #{params[:client_key]}") Rails.logger.info("00000 #{params[:timestamp]}") - tip_exception(501, "请求超时") if Time.now - params[:timestamp].to_i > 5 + tip_exception(501, "请求超时") if (Time.now - params[:timestamp].to_i).between(0,5) timestamp = params[:timestamp] sign = Digest::MD5.hexdigest("#{OPENKEY}#{timestamp}") Rails.logger.info("2222 #{sign}") From d81387c8e7858831e296d21b64c88365c82d43ed Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 30 Dec 2019 16:49:53 +0800 Subject: [PATCH 3/5] 1 --- app/controllers/application_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 4daa3b45c..63c32f7e6 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -27,7 +27,8 @@ class ApplicationController < ActionController::Base if params[:client_key].present? Rails.logger.info("111111 #{params[:client_key]}") Rails.logger.info("00000 #{params[:timestamp]}") - tip_exception(501, "请求超时") if (Time.now - params[:timestamp].to_i).between(0,5) + Rails.logger.info("Time.now - params[:timestamp].to_i: #{Time.now - params[:timestamp].to_i}") + tip_exception(501, "请求超时") unless (Time.now - params[:timestamp].to_i).between(0,5) timestamp = params[:timestamp] sign = Digest::MD5.hexdigest("#{OPENKEY}#{timestamp}") Rails.logger.info("2222 #{sign}") From 9f02077d434cc1da84ae338e5272b70f8a72de99 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 30 Dec 2019 16:51:02 +0800 Subject: [PATCH 4/5] 1 --- app/controllers/application_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 63c32f7e6..3bad1718c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -27,8 +27,8 @@ class ApplicationController < ActionController::Base if params[:client_key].present? Rails.logger.info("111111 #{params[:client_key]}") Rails.logger.info("00000 #{params[:timestamp]}") - Rails.logger.info("Time.now - params[:timestamp].to_i: #{Time.now - params[:timestamp].to_i}") - tip_exception(501, "请求超时") unless (Time.now - params[:timestamp].to_i).between(0,5) + Rails.logger.info("Time.now - params[:timestamp].to_i: #{Time.now.to_i - params[:timestamp].to_i}") + tip_exception(501, "请求超时") unless (Time.now.to_i - params[:timestamp].to_i).between(0,5) timestamp = params[:timestamp] sign = Digest::MD5.hexdigest("#{OPENKEY}#{timestamp}") Rails.logger.info("2222 #{sign}") From 7742f99aeb7d45faa85ab1d565df5d6c4155a8bf Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 30 Dec 2019 16:53:49 +0800 Subject: [PATCH 5/5] 1 --- app/controllers/application_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 3bad1718c..65c05ef2a 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -28,7 +28,7 @@ class ApplicationController < ActionController::Base Rails.logger.info("111111 #{params[:client_key]}") Rails.logger.info("00000 #{params[:timestamp]}") Rails.logger.info("Time.now - params[:timestamp].to_i: #{Time.now.to_i - params[:timestamp].to_i}") - tip_exception(501, "请求超时") unless (Time.now.to_i - params[:timestamp].to_i).between(0,5) + tip_exception(501, "请求超时") unless (Time.now.to_i - params[:timestamp].to_i).between?(0,5) timestamp = params[:timestamp] sign = Digest::MD5.hexdigest("#{OPENKEY}#{timestamp}") Rails.logger.info("2222 #{sign}")