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

dev_sync_trustie
cxt 5 years ago
commit 2983721f36

@ -11,6 +11,10 @@ class SchoolsController < ApplicationController
end end
def for_option def for_option
render_ok(schools: School.select(:id, :name).as_json) schools = School.all
keyword = params[:keyword].to_s.strip
schools = schools.where('name LIKE ?', "%#{keyword}%") if keyword
render_ok(schools: schools.select(:id, :name).as_json)
end end
end end

@ -0,0 +1,38 @@
class Weapps::CheckAccountsController < Weapps::BaseController
def create
params[:type] == 'register' ? check_can_register : check_can_bind
end
private
def check_can_bind
if params[:login] =~ /^[a-zA-Z0-9]+([._\\]*[a-zA-Z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/
user = User.find_by(mail: params[:login])
return render_error('该邮箱尚未注册') if user.blank?
elsif params[:login] =~ /^1\d{10}$/
user = User.find_by(phone: params[:login])
return render_error('该手机号尚未注册') if user.blank?
else
user = User.find_by(login: params[:login])
return render_error('该账号尚未注册') if user.blank?
end
return render_error('该账号已经绑定') if user.wechat_open_user.present?
render_ok
end
def check_can_register
if params[:login] =~ /^[a-zA-Z0-9]+([._\\]*[a-zA-Z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/
user = User.find_by(mail: params[:login])
return render_error('该邮箱已注册') if user.present?
elsif params[:login] =~ /^1\d{10}$/
user = User.find_by(phone: params[:login])
return render_error('该手机号已注册') if user.present?
else
return render_error('请输入正确的邮箱或手机号')
end
render_ok
end
end

@ -15,6 +15,17 @@ module ApplicationHelper
EduSetting.get(name) EduSetting.get(name)
end end
# xss共计问题
def content_safe content
tags = %w(
a abbr b bdo blockquote br caption cite code col colgroup dd del dfn dl
dt em figcaption figure h1 h2 h3 h4 h5 h6 hgroup i img ins kbd li mark
ol p pre q rp rt ruby s samp small strike strong sub sup table tbody td
tfoot th thead time tr u ul var wbr div span
)
sanitize content, tags: tags
end
def graduation_navigation graduation def graduation_navigation graduation
graduation.class.to_s == "GraduationTopic" ? "毕设选题" : "毕设任务" graduation.class.to_s == "GraduationTopic" ? "毕设选题" : "毕设任务"
end end

@ -36,7 +36,7 @@ class Admins::ImportCourseMemberService < ApplicationService
member = course.course_members.find_by(user_id: user.id, role: data.role.to_i) member = course.course_members.find_by(user_id: user.id, role: data.role.to_i)
# 如果已是课堂成员且是学生身份and不在指定的分班则移动到该分班 # 如果已是课堂成员且是学生身份and不在指定的分班则移动到该分班
if member.present? && member.role == :STUDENT && course_group && member.course_group_id != course_group&.id if member.present? && member.role == 'STUDENT' && course_group && member.course_group_id != course_group&.id
member.update!(course_group_id: course_group&.id) member.update!(course_group_id: course_group&.id)
elsif member.blank? elsif member.blank?
course.course_members.create!(user_id: user.id, role: data.role.to_i, course_group_id: course_group&.id) course.course_members.create!(user_id: user.id, role: data.role.to_i, course_group_id: course_group&.id)

@ -2,7 +2,7 @@ json.author do
json.partial! 'users/user', user: discuss.user json.partial! 'users/user', user: discuss.user
end end
json.id discuss.id json.id discuss.id
json.content discuss.content json.content content_safe(discuss.content)
json.time time_from_now(discuss.created_at) json.time time_from_now(discuss.created_at)
json.position discuss.position json.position discuss.position
json.shixun_id discuss.dis_id json.shixun_id discuss.dis_id

@ -3,7 +3,7 @@ json.memo do
json.forum_id memo.forum_id json.forum_id memo.forum_id
json.subject memo.subject json.subject memo.subject
json.is_md memo.is_md json.is_md memo.is_md
json.content memo.content json.content content_safe(memo.content)
json.sticky memo.sticky json.sticky memo.sticky
json.reward memo.reward json.reward memo.reward
json.viewed_count memo.viewed_count json.viewed_count memo.viewed_count

@ -1,5 +1,5 @@
json.id memo.id json.id memo.id
json.content memo.content json.content content_safe(memo.content)
json.time time_from_now(memo.created_at) json.time time_from_now(memo.created_at)
json.user_id memo.author_id json.user_id memo.author_id
json.image_url url_to_avatar(memo.author) json.image_url url_to_avatar(memo.author)
@ -15,7 +15,7 @@ json.admin @user.admin? || @user.business?
json.children do json.children do
json.array! memo.children_of_reply do |child| json.array! memo.children_of_reply do |child|
json.id child.id json.id child.id
json.content child.content json.content content_safe(child.content)
json.time time_from_now(child.created_at) json.time time_from_now(child.created_at)
json.image_url url_to_avatar(child.author) json.image_url url_to_avatar(child.author)
json.username child.author.full_name json.username child.author.full_name

@ -1 +1 @@
json.content content json.content content_safe(content)

@ -1,6 +1,6 @@
json.partial! "messages/message_simple", message: message json.partial! "messages/message_simple", message: message
json.partial! "commons/like", message: message json.partial! "commons/like", message: message
json.content message.message_detail.try(:content) json.content content_safe(message.message_detail.try(:content))
json.author do json.author do
json.partial! "users/user_simple", user: message.author json.partial! "users/user_simple", user: message.author
end end

@ -854,6 +854,7 @@ Rails.application.routes.draw do
resource :register, only: [:create] resource :register, only: [:create]
resource :code_session, only: [:create] resource :code_session, only: [:create]
resource :verify, only: [:create] resource :verify, only: [:create]
resource :check_account, only: [:create]
resources :searchs, only: [:index] resources :searchs, only: [:index]
end end

@ -1,6 +1,6 @@
class AddIsInvalidToStudentWorksScores < ActiveRecord::Migration[5.2] class AddIsInvalidToStudentWorksScores < ActiveRecord::Migration[5.2]
def change def change
# add_column :student_works_scores, :is_invalid, :boolean, default: false add_column :student_works_scores, :is_invalid, :boolean, default: false
StudentWorksScore.where("score is not null").order("id desc").find_each do |score| StudentWorksScore.where("score is not null").order("id desc").find_each do |score|
unless score.is_invalid unless score.is_invalid

Loading…
Cancel
Save