From 1837595cf29ad77ee6746252dd6c93f87708c9a1 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Mon, 30 Dec 2019 17:45:47 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E5=99=A8=E6=97=B6=E9=97=B4=E8=8E=B7=E5=8F=96=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/ecs/homes_controller.rb | 4 ---- app/controllers/main_controller.rb | 4 ++++ config/routes.rb | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/ecs/homes_controller.rb b/app/controllers/ecs/homes_controller.rb index 2202f6882..7edbd7d78 100644 --- a/app/controllers/ecs/homes_controller.rb +++ b/app/controllers/ecs/homes_controller.rb @@ -3,10 +3,6 @@ class Ecs::HomesController < Ecs::BaseController @school_managers = current_school.users end - def first_stamp - render :json => { status: 0, message: Time.now.to_i } - end - private def current_school diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb index 395e536f4..e8554300c 100644 --- a/app/controllers/main_controller.rb +++ b/app/controllers/main_controller.rb @@ -1,6 +1,10 @@ class MainController < ApplicationController skip_before_action :check_sign + def first_stamp + render :json => { status: 0, message: Time.now.to_i } + end + def index render file: 'public/react/build/index.html', :layout => false end diff --git a/config/routes.rb b/config/routes.rb index c569596cc..c9da309d2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -15,7 +15,7 @@ Rails.application.routes.draw do scope '/api' do get 'home/index' get 'home/search' - get 'home/first_stamp' + get 'main/first_stamp' get 'search', to: 'searchs#index' From 7fc0d1689989cd429c895a54820051eae885614c Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Mon, 30 Dec 2019 17:59:11 +0800 Subject: [PATCH 2/2] randomcode --- app/controllers/application_controller.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 5abb3d69a..377230451 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -25,11 +25,10 @@ class ApplicationController < ActionController::Base def check_sign Rails.logger.info("66666 #{params}") if params[:client_key].present? - Rails.logger.info("111111 #{params[:client_key]}") - Rails.logger.info("00000 #{params[:timestamp]}") - tip_exception(501, "请求不合理") unless (Time.now.to_i - params[:timestamp].to_i).between?(0,5) - timestamp = params[:timestamp] - sign = Digest::MD5.hexdigest("#{OPENKEY}#{timestamp}") + randomcode = params[:randomcode] + tip_exception(501, "请求不合理") unless (Time.now.to_i - randomcode.to_i).between?(0,5) + + sign = Digest::MD5.hexdigest("#{OPENKEY}#{randomcode}") Rails.logger.info("2222 #{sign}") tip_exception(501, "请求不合理") if sign != params[:client_key] else