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

dev_oauth
hjm 6 years ago
commit 2a9fc4d6cb

@ -42,4 +42,13 @@ module Util
return '' if str.blank?
str.gsub(/<\/?.*?>/, '').gsub(/[\n\t\r]/, '').gsub(/&nbsp;/, '')
end
def conceal(str, type = nil)
str = str.to_s
case type
when :phone then "#{str[0..2]}***#{str[-4..-1]}"
when :email then "#{str[0..2]}***#{str[str.rindex('@')..-1]}"
else "#{str[0..2]}***#{str[-3..-1]}"
end
end
end

@ -11,7 +11,7 @@ class Users::BindEmailService < ApplicationService
def call
Users::BindEmailForm.new(params).validate!
raise Error, '该邮箱已被绑定' if User.where.not(id: user.id).exists?(mail: params[:email])
raise Error, '该邮箱已被其他账号绑定' if User.where.not(id: user.id).exists?(mail: params[:email])
code = VerificationCode.where(email: params[:email], code: params[:code], code_type: 5).last
raise Error, '验证码无效' unless code&.effective?

@ -11,7 +11,7 @@ class Users::BindPhoneService < ApplicationService
def call
Users::BindPhoneForm.new(params).validate!
raise Error, '该手机号已被绑定' if User.where.not(id: user.id).exists?(phone: params[:phone])
raise Error, '该手机号已被其他账号绑定' if User.where.not(id: user.id).exists?(phone: params[:phone])
code = VerificationCode.where(phone: params[:phone], code: params[:code], code_type: 4).last
raise Error, '验证码无效' unless code&.effective?

Loading…
Cancel
Save