From 67fa600409c09febe799a6092e557eb3ef67d0d7 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Mon, 23 Dec 2019 09:38:50 +0800 Subject: [PATCH 1/6] =?UTF-8?q?403=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/cooperative/base_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/cooperative/base_controller.rb b/app/controllers/cooperative/base_controller.rb index 51af05ed2..dfc99b7b8 100644 --- a/app/controllers/cooperative/base_controller.rb +++ b/app/controllers/cooperative/base_controller.rb @@ -16,7 +16,7 @@ class Cooperative::BaseController < ApplicationController private def current_laboratory - @_current_laboratory ||= Laboratory.find_by_subdomain(request.subdomain) + @_current_laboratory ||= (Laboratory.find_by_subdomain(request.subdomain) || Laboratory.first) # @_current_laboratory ||= Laboratory.find 1 end From 520eb4c5f0d0be851422d8c98e3f0766630e094e Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Sat, 28 Dec 2019 18:15:19 +0800 Subject: [PATCH 2/6] .. --- app/views/admins/laboratories/index.html.erb | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/app/views/admins/laboratories/index.html.erb b/app/views/admins/laboratories/index.html.erb index 397f50cbe..ed4df3c90 100644 --- a/app/views/admins/laboratories/index.html.erb +++ b/app/views/admins/laboratories/index.html.erb @@ -1,19 +1 @@ -<% define_admin_breadcrumbs do %> - <% add_admin_breadcrumb('云上实验室') %> -<% end %> - -
- <%= form_tag(admins_laboratories_path(unsafe_params), method: :get, class: 'form-inline search-form flex-1', remote: true) do %> - <%= text_field_tag(:keyword, params[:keyword], class: 'form-control col-6 col-md-4 ml-3', placeholder: '学校名称/二级域名前缀检索') %> - <%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %> - <% end %> - - <%= javascript_void_link '新建', class: 'btn btn-primary', data: { toggle: 'modal', target: '.admin-create-laboratory-modal' } %> -
- -
- <%= render(partial: 'admins/laboratories/shared/list', locals: { laboratories: @laboratories }) %> -
- -<%= render 'admins/laboratories/shared/create_laboratory_modal' %> -<%= render 'admins/laboratories/shared/add_laboratory_user_modal' %> \ No newline at end of file +666 \ No newline at end of file From b1e04695e3c64c884fa12292f3c10827265446b7 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Sat, 28 Dec 2019 18:16:22 +0800 Subject: [PATCH 3/6] .. --- app/views/admins/laboratories/index.html.erb | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/app/views/admins/laboratories/index.html.erb b/app/views/admins/laboratories/index.html.erb index ed4df3c90..397f50cbe 100644 --- a/app/views/admins/laboratories/index.html.erb +++ b/app/views/admins/laboratories/index.html.erb @@ -1 +1,19 @@ -666 \ No newline at end of file +<% define_admin_breadcrumbs do %> + <% add_admin_breadcrumb('云上实验室') %> +<% end %> + +
+ <%= form_tag(admins_laboratories_path(unsafe_params), method: :get, class: 'form-inline search-form flex-1', remote: true) do %> + <%= text_field_tag(:keyword, params[:keyword], class: 'form-control col-6 col-md-4 ml-3', placeholder: '学校名称/二级域名前缀检索') %> + <%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %> + <% end %> + + <%= javascript_void_link '新建', class: 'btn btn-primary', data: { toggle: 'modal', target: '.admin-create-laboratory-modal' } %> +
+ +
+ <%= render(partial: 'admins/laboratories/shared/list', locals: { laboratories: @laboratories }) %> +
+ +<%= render 'admins/laboratories/shared/create_laboratory_modal' %> +<%= render 'admins/laboratories/shared/add_laboratory_user_modal' %> \ No newline at end of file From fc0f9cb0d195eaa075ce36f38b3286f61d5f5830 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Mon, 30 Dec 2019 10:00:48 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E8=AF=B7=E6=B1=82=E7=AD=BE=E5=90=8D?= =?UTF-8?q?=E8=BF=87=E6=BB=A4=E4=B8=8D=E5=90=88=E7=90=86=E8=AF=B7=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index c0905e89c..19fc3adf1 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -12,6 +12,7 @@ class ApplicationController < ActionController::Base protect_from_forgery prepend: true, unless: -> { request.format.json? } + before_action :check_sign before_action :user_setup #before_action :check_account @@ -20,6 +21,13 @@ class ApplicationController < ActionController::Base helper_method :current_user + # 所有请求必须合法签名 + def check_sign + timestamp = Time.now.to_i + sign = Digest::MD5.hexdigest("#{OPENKEY}#{timestamp}") + tip_exception(501, "请求不合理") if sign != params[:client_key] + end + # 全局配置参数 # 返回name对应的value def edu_setting(name) From 93b58cdd87561bd47c5cbf987d187f37cbf34103 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Mon, 30 Dec 2019 10:03:25 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E6=97=B6=E9=97=B4=E6=88=B3=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= 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 19fc3adf1..905b2c41d 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -23,7 +23,7 @@ class ApplicationController < ActionController::Base # 所有请求必须合法签名 def check_sign - timestamp = Time.now.to_i + timestamp = params[:timestamp] sign = Digest::MD5.hexdigest("#{OPENKEY}#{timestamp}") tip_exception(501, "请求不合理") if sign != params[:client_key] end From e4e7b6e26d9818c4f3dbacebb36a53e86d67a01c Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 30 Dec 2019 10:27:46 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E8=B7=B3=E8=BF=87=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/hack_user_lastest_codes_controller.rb | 2 +- app/controllers/myshixuns_controller.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/hack_user_lastest_codes_controller.rb b/app/controllers/hack_user_lastest_codes_controller.rb index 641dcae2d..38238fea7 100644 --- a/app/controllers/hack_user_lastest_codes_controller.rb +++ b/app/controllers/hack_user_lastest_codes_controller.rb @@ -153,7 +153,7 @@ class HackUserLastestCodesController < ApplicationController when 'Java' content.scan(/.java.\d+/).map{|s| s.match(/\d+/)[0].to_i}.min when 'C', 'C++' - content.scan(/\d:\d+:/).map{|s| s.match(/\d+/)[0]}.min + content.scan(/\d:\d+:/).map{|s| s.match(/\d+/)[0].to_i}.min when 'Python' content.scan(/line \d+/).map{|s| s.match(/\d+/)[0].to_i}.min end diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index 255c0f42e..67bec877b 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -3,6 +3,7 @@ class MyshixunsController < ApplicationController before_action :find_myshixun, :except => [:training_task_status, :code_runinng_message] before_action :find_repo_name, :except => [:training_task_status, :code_runinng_message] skip_before_action :verify_authenticity_token, :only => [:html_content] + skip_before_action :check_sign, only: [:training_task_status, :code_runinng_message] ## TPI关卡列表 def challenges