From 6cb82826aa7238e7b5d7715ee7067b57a7adb2d0 Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 15 Mar 2019 09:11:04 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E6=B3=A8=E5=86=8C=E3=80=91=E3=80=90?= =?UTF-8?q?=E9=9C=80=E6=B1=82=E3=80=91=E6=B5=8B=E8=AF=95=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=80=E4=B8=AA=E4=B8=87=E8=83=BD=E9=AA=8C?= =?UTF-8?q?=E8=AF=81=E7=A0=81=E6=96=B9=E4=BE=BF=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/account_controller.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 7be3e8e3..34552787 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -677,12 +677,16 @@ class AccountController < ApplicationController req = Hash.new(false) req[:valid] = false type = params[:type].to_i - 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 + if Redmine::Configuration['gitlab_address'].include?("test") && params[:code] == "134790" + req[:valid] = true else - code = VerificationCode.where(:email => params[:phone], :code => params[:code], :code_type => params[:type].to_i).last + 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 + else + code = VerificationCode.where(:email => params[:phone], :code => params[:code], :code_type => params[:type].to_i).last + end + req[:valid] = !code.nil? && (Time.now.to_i - code.created_at.to_i) <= 10*60 end - req[:valid] = !code.nil? && (Time.now.to_i - code.created_at.to_i) <= 10*60 render :json => req end