|
|
|
@ -19,11 +19,10 @@ class Weapps::VerificationCodesController < Weapps::BaseController
|
|
|
|
|
return render_error('请输入正确的邮箱或手机号')
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
code = %W(0 1 2 3 4 5 6 7 8 9)
|
|
|
|
|
verification_code = code.sample(6).join
|
|
|
|
|
send_type = login =~ /^1\d{10}$/ ? 1 : 8
|
|
|
|
|
# 记录验证码
|
|
|
|
|
check_verification_code(verification_code, send_type, login)
|
|
|
|
|
|
|
|
|
|
# 发送验证码
|
|
|
|
|
send_code(send_type, login)
|
|
|
|
|
|
|
|
|
|
render_ok
|
|
|
|
|
end
|
|
|
|
@ -40,12 +39,21 @@ class Weapps::VerificationCodesController < Weapps::BaseController
|
|
|
|
|
return render_error('请输入正确的邮箱或手机号')
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
send_type = login =~ /^1\d{10}$/ ? 2 : 3
|
|
|
|
|
|
|
|
|
|
# 发送验证码
|
|
|
|
|
send_code(send_type, login)
|
|
|
|
|
|
|
|
|
|
render_ok
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def send_code send_type, login
|
|
|
|
|
code = %W(0 1 2 3 4 5 6 7 8 9)
|
|
|
|
|
verification_code = code.sample(6).join
|
|
|
|
|
send_type = login =~ /^1\d{10}$/ ? 2 : 3
|
|
|
|
|
# 记录验证码
|
|
|
|
|
check_verification_code(verification_code, send_type, login)
|
|
|
|
|
sign = Digest::MD5.hexdigest("#{OPENKEY}#{login}")
|
|
|
|
|
tip_exception(501, "请求不合理") if sign != params[:smscode]
|
|
|
|
|
|
|
|
|
|
render_ok
|
|
|
|
|
check_verification_code(verification_code, send_type, login)
|
|
|
|
|
end
|
|
|
|
|
end
|