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

dev_forum
jingquan huang 5 years ago
commit b45438b205

@ -31,10 +31,11 @@ class AccountsController < ApplicationController
verifi_code = VerificationCode.where(email: email, code: code, code_type: 8).last
end
uid_logger("start register: verifi_code is #{verifi_code}, code is #{code}, time is #{Time.now.to_i - verifi_code.try(:created_at).to_i}")
check_code = (verifi_code.try(:code) == code.strip && (Time.now.to_i - verifi_code.created_at.to_i) <= 10*60)
# todo 上线前请删除
if !check_code && code != "513231"
tip_exception("验证码无效")
# check_code = (verifi_code.try(:code) == code.strip && (Time.now.to_i - verifi_code.created_at.to_i) <= 10*60)
# todo 上线前请删除万能验证码"513231"
if code != "513231"
tip_exception(-2, "验证码不正确") if verifi_code.try(:code) != code.strip
tip_exception(-2, "验证码已失效") if (Time.now.to_i - verifi_code.created_at.to_i) <= 10*60
end
code = generate_identifier User, 8
@ -56,6 +57,7 @@ class AccountsController < ApplicationController
)
successful_authentication(@user)
session[:user_id] = @user.id
normal_status("注册成功")
end
rescue Exception => e
uid_logger_error(e.message)
@ -88,10 +90,8 @@ class AccountsController < ApplicationController
verifi_code = VerificationCode.where(email: email, code: code, code_type: 3).last
user = User.find_by_mail(email) #这里有问题应该是为email,而不是mail 6.13-hs
end
check_code = (verifi_code.try(:code) == code.strip && (Time.now.to_i - verifi_code.created_at.to_i) <= 10*60)
unless check_code
tip_exception("验证码无效")
end
tip_exception(-2, "验证码不正确") if verifi_code.try(:code) != code.strip
tip_exception(-2, "验证码已失效") if (Time.now.to_i - verifi_code.created_at.to_i) <= 10*60
user.password, user.password_confirmation = params[:new_password], params[:new_password_confirmation]
if user.save!

@ -995,7 +995,8 @@ class HomeworkCommonsController < ApplicationController
else
@subjects = @subjects[offset, limit]
subject_ids = @subjects.pluck(:id)
@subjects = Subject.where(id: subject_ids).order("field(id,#{subject_ids.join(',')})").includes(:shixuns, user: [user_extension: :school])
order_ids = subject_ids.size > 0 ? subject_ids.join(',') : -1
@subjects = Subject.where(id: subject_ids).order("field(id,#{order_ids})").includes(:shixuns, user: [user_extension: :school])
end
end

@ -69,7 +69,8 @@ class SubjectsController < ApplicationController
else
@subjects = @subjects[offset, limit]
subject_ids = @subjects.pluck(:id)
@subjects = Subject.where(id: subject_ids).order("field(id,#{subject_ids.join(',')})").includes(:shixuns, :repertoire)
order_ids = subject_ids.size > 0 ? subject_ids.join(',') : -1
@subjects = Subject.where(id: subject_ids).order("field(id,#{order_ids})").includes(:shixuns, :repertoire)
end
end

@ -509,10 +509,10 @@ class User < ApplicationRecord
if user
# user is already in local database
raise("账号已被注销,请联系管理员") if user.locked?
raise("密码错误") unless user.check_password?(password)
raise Educoder::TipException.new(-2, "违反平台使用规范,账号已被锁定") if user.locked?
raise Educoder::TipException.new(-2, "错误的账号或密码") unless user.check_password?(password)
else
raise("账号未注册")
raise Educoder::TipException.new(-2, "错误的账号或密码")
end
user

@ -9,6 +9,8 @@ class Users::ApplyAuthenticationService < ApplicationService
end
def call
raise Error, '请先完善基本信息' unless user.profile_completed?
Users::ApplyAuthenticationForm.new(params).validate!
raise Error, '您已经申请过实名认证了' if ApplyUserAuthentication.real_name_auth.processing.exists?(user_id: user.id)

@ -9,6 +9,8 @@ class Users::ApplyProfessionalAuthService < ApplicationService
end
def call
raise Error, '请先完善基本信息' unless user.profile_completed?
Users::ApplyProfessionalAuthForm.new(params).validate!
raise Error, '您已经申请过职业认证了' if ApplyUserAuthentication.professional_auth.processing.exists?(user_id: user.id)

@ -1 +0,0 @@
json.redirect_uri subjects_url

@ -5,6 +5,7 @@ json.results do
json.type obj.class.name.downcase
json.title highlights.delete(:name)&.join('...') || obj.searchable_title
json.description highlights.values[0,5].each { |arr| arr.is_a?(Array) ? arr.join('...') : arr }.join('<br/>')
# json.description highlights.values[0,5].each { |arr| arr.is_a?(Array) ? arr.join('...') : arr }.join('<br/>')
json.content highlights
end
end

@ -4,6 +4,7 @@ json.user_id @user.id
json.image_url url_to_avatar(@user)
json.admin @user.admin?
json.is_teacher @user.user_extension&.teacher?
json.user_identity @user.identity
json.tidding_count 0
json.user_phone_binded @user.phone.present?
if @course

Loading…
Cancel
Save