修复漏洞

dev_local
daiao 5 years ago
parent efa374c56b
commit 951f1a76bc

@ -10,7 +10,7 @@ class QuestionBanksController < ApplicationController
def bank_list def bank_list
page = params[:page] || 1 page = params[:page] || 1
limit = params[:limit] || 15 limit = params[:limit] || 15
@certification_teacher = current_user.is_teacher? || current_user.admin? @certification_teacher = current_user.is_certification_teacher || current_user.admin_or_business?
@objects = @object_type.classify.constantize.where(@object_filter) @objects = @object_type.classify.constantize.where(@object_filter)
@objects = @objects =
if params[:search] if params[:search]
@ -18,19 +18,17 @@ class QuestionBanksController < ApplicationController
# 已认证才能获取题库 # 已认证才能获取题库
if @certification_teacher if @certification_teacher
sql = %Q{ sql = %Q{
#{@objects.table_name}.is_public = 1 and concat(#{@objects.table_name}.name, course_lists.name) like #{@objects.table_name}.is_public = 1 and concat(#{@objects.table_name}.name, course_lists.name) like :keyword
'%#{params[:search]}%' }
} @objects.joins(:course_list).where(sql, keyword: "%#{params[:search]}%")
@objects.joins(:course_list).where(sql)
else else
@objects.none @objects.none
end end
else else
sql = %Q{ sql = %Q{
#{@objects.table_name}.user_id = #{current_user.id} and concat(#{@objects.table_name}.name, course_lists.name) like #{@objects.table_name}.user_id = #{current_user.id} and concat(#{@objects.table_name}.name, course_lists.name) like :keyword
'%#{params[:search]}%' }
} @objects.joins(:course_list).where(sql, keyword: "%#{params[:search]}%")
@objects.joins(:course_list).where(sql)
end end
else else
if params[:filter] == 'public' if params[:filter] == 'public'

Loading…
Cancel
Save