Merge branch 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

dev_tpm_ui
杨树林 5 years ago
commit 80b188bb24

@ -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

@ -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,21 @@ class ApplicationController < ActionController::Base
helper_method :current_user
# 所有请求必须合法签名
def check_sign
Rails.logger.info("66666 #{params}")
if params[:client_key].present?
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
tip_exception(501, "请求不合理")
end
end
# 全局配置参数
# 返回name对应的value
def edu_setting(name)

@ -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

@ -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

@ -1,4 +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

@ -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

@ -15,6 +15,7 @@ Rails.application.routes.draw do
scope '/api' do
get 'home/index'
get 'home/search'
get 'main/first_stamp'
get 'search', to: 'searchs#index'
@ -1336,6 +1337,7 @@ Rails.application.routes.draw do
root 'main#index'
## react用
get '*path', to: 'main#index', constraints: ReactConstraint.new
end

@ -49,6 +49,7 @@
"lodash": "^4.17.5",
"loglevel": "^1.6.1",
"material-ui": "^1.0.0-beta.40",
"md5": "^2.2.1",
"moment": "^2.23.0",
"monaco-editor": "^0.15.6",
"monaco-editor-webpack-plugin": "^1.7.0",

@ -1,10 +1,12 @@
import React from "react";
import axios from 'axios';
import md5 from 'md5';
import { requestProxy } from "./indexEduplus2RequestProxy";
import { broadcastChannelOnmessage ,SetAppModel, isDev, queryString } from 'educoder';
import { notification } from 'antd';
import './index.css'
import './index.css';
const opens ="79e33abd4b6588941ab7622aed1e67e8";
broadcastChannelOnmessage('refreshPage', () => {
window.location.reload()
})
@ -90,21 +92,23 @@ export function initAxiosInterceptors(props) {
}
}
if(`${config[0]}`!=`true`){
let timestamp = Date.parse(new Date())/1000;
let newopens=md5(opens+timestamp)
if (window.location.port === "3007") {
// if (url.indexOf('.json') == -1) {
//
// alert('开发提示:请给接口加.json:' + url)
//
// }
config.url = `${proxy}${url}`;
if (config.url.indexOf('?') == -1) {
config.url = `${config.url}?debug=${debugType}`;
config.url = `${config.url}?debug=${debugType}&timestamp=${timestamp}&client_key=${newopens}`;
} else {
config.url = `${config.url}&debug=${debugType}`;
config.url = `${config.url}&debug=${debugType}&timestamp=${timestamp}&client_key=${newopens}`;
}
} else {
// 加api前缀
config.url = url;
config.url = url;
if (config.url.indexOf('?') == -1) {
config.url = `${config.url}?&timestamp=${timestamp}&client_key=${newopens}`;
} else {
config.url = `${config.url}&timestamp=${timestamp}&client_key=${newopens}`;
}
}
}
//
@ -191,6 +195,11 @@ export function initAxiosInterceptors(props) {
locationurl('/500');
}
if (response.data.status === 501) {
notification.warning({
description:response.data.message || '访问异常,请求不合理',
})
}
// if (response.data.status === 402) {

@ -285,10 +285,10 @@ class Bullsubdirectory extends Component{
const {getFieldDecorator} = this.props.form;
// console.log("Bullsubdirectory");
// console.log(this.props.isAdmin());
console.log(this.props);
console.log(whethertoeditysl);
console.log(this.state.eduintits);
console.log(this.state.description);
// console.log(this.props);
// console.log(whethertoeditysl);
// console.log(this.state.eduintits);
// console.log(this.state.description);
return(
<React.Fragment key={this.props.index} id={this.props.id}>

Loading…
Cancel
Save