From a67a9edfb0e6b5418316f3835483ccf4364e4aac Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 23 Oct 2019 14:32:43 +0800 Subject: [PATCH] =?UTF-8?q?=E9=82=AE=E4=BB=B6=E9=85=8D=E7=BD=AE=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 4 ++-- app/libs/limit_forbid_control/base.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 6ad488f48..db72590ee 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -88,11 +88,11 @@ class ApplicationController < ActionController::Base sigle_para = {email: value} # 60s内不能重复发送 send_email_limit_cache_key = "send_email_60_second_limit:#{value}" - tip_exception(-2, '请勿频繁操作') if Rails.cache.exist?(send_email_limit_cache_key) + tip_exception(-1, '请勿频繁操作') if Rails.cache.exist?(send_email_limit_cache_key) # 短时间内不能大量发送 send_email_control = LimitForbidControl::SendEmailCode.new(value) - tip_exception(-2, '邮件发送太频繁,请稍后再试') if send_email_control.forbid? + tip_exception(-1, '邮件发送太频繁,请稍后再试') if send_email_control.forbid? begin UserMailer.register_email(value, code).deliver_now diff --git a/app/libs/limit_forbid_control/base.rb b/app/libs/limit_forbid_control/base.rb index a437f48b6..f112c1df7 100644 --- a/app/libs/limit_forbid_control/base.rb +++ b/app/libs/limit_forbid_control/base.rb @@ -31,7 +31,7 @@ class LimitForbidControl::Base value = value.to_i + 1 # 锁定 - if value > allow_times.to_i + if value >= allow_times.to_i Rails.cache.write(forbid_cache_key, true, expires_in: forbid_expires) Rails.cache.delete(cache_key) else