From 0f822648408d4b4aaca4672be3874af05ebc36d2 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 13 Jan 2020 17:18:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E5=8F=91=E9=80=81=E9=AA=8C?= =?UTF-8?q?=E8=AF=81=E7=A0=81=E5=8A=A0=E5=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weapps/verification_codes_controller.rb | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/app/controllers/weapps/verification_codes_controller.rb b/app/controllers/weapps/verification_codes_controller.rb index 7590c49f7..1876014db 100644 --- a/app/controllers/weapps/verification_codes_controller.rb +++ b/app/controllers/weapps/verification_codes_controller.rb @@ -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 \ No newline at end of file