【注册】【需求】测试环境增加一个万能验证码方便测试

dev_shixuns
cxt 6 years ago
parent 211aaa49fa
commit 6cb82826aa

@ -677,12 +677,16 @@ class AccountController < ApplicationController
req = Hash.new(false) req = Hash.new(false)
req[:valid] = false req[:valid] = false
type = params[:type].to_i type = params[:type].to_i
if Redmine::Configuration['gitlab_address'].include?("test") && params[:code] == "134790"
req[:valid] = true
else
if type == 1 || type == 2 || type == 4 || type == 6 || params[:phone] =~ /^1\d{10}$/ if type == 1 || type == 2 || type == 4 || type == 6 || params[:phone] =~ /^1\d{10}$/
code = VerificationCode.where(:phone => params[:phone], :code => params[:code], :code_type => (params[:type].to_i != 1 && params[:type].to_i != 2 && params[:type].to_i != 4) ? 2 : params[:type].to_i ).last code = VerificationCode.where(:phone => params[:phone], :code => params[:code], :code_type => (params[:type].to_i != 1 && params[:type].to_i != 2 && params[:type].to_i != 4) ? 2 : params[:type].to_i ).last
else else
code = VerificationCode.where(:email => params[:phone], :code => params[:code], :code_type => params[:type].to_i).last code = VerificationCode.where(:email => params[:phone], :code => params[:code], :code_type => params[:type].to_i).last
end end
req[:valid] = !code.nil? && (Time.now.to_i - code.created_at.to_i) <= 10*60 req[:valid] = !code.nil? && (Time.now.to_i - code.created_at.to_i) <= 10*60
end
render :json => req render :json => req
end end

Loading…
Cancel
Save