mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-03 03:40:49 +08:00
Merge branch 'develop' into standalone_develop
This commit is contained in:
@@ -9,21 +9,24 @@ class Api::V1::UsersController < Api::V1::BaseController
|
||||
mail = params[:email]
|
||||
code_type = params[:code_type]
|
||||
|
||||
status, message = InfoRiskControlService.call(0, request.remote_ip)
|
||||
tip_exception(420, message) if status == 0
|
||||
|
||||
sign = Digest::MD5.hexdigest("#{OPENKEY}#{mail}")
|
||||
Rails.logger.info sign
|
||||
|
||||
tip_exception(501, "请求不合理") if sign != params[:smscode]
|
||||
|
||||
# 60s内不能重复发送
|
||||
send_email_limit_cache_key = "send_email_60_second_limit:#{mail}"
|
||||
tip_exception(-2, '请勿频繁操作') if Rails.cache.exist?(send_email_limit_cache_key)
|
||||
send_email_control = LimitForbidControl::SendEmailCode.new(mail)
|
||||
tip_exception(-2, '邮件发送太频繁,请稍后再试') if send_email_control.forbid?
|
||||
# send_email_limit_cache_key = "send_email_60_second_limit:#{mail}"
|
||||
# tip_exception(-2, '请勿频繁操作') if Rails.cache.exist?(send_email_limit_cache_key)
|
||||
# send_email_control = LimitForbidControl::SendEmailCode.new(mail)
|
||||
# tip_exception(-2, '邮件发送太频繁,请稍后再试') if send_email_control.forbid?
|
||||
begin
|
||||
UserMailer.update_email(mail, verification_code).deliver_now
|
||||
|
||||
Rails.cache.write(send_email_limit_cache_key, 1, expires_in: 1.minute)
|
||||
send_email_control.increment!
|
||||
# Rails.cache.write(send_email_limit_cache_key, 1, expires_in: 1.minute)
|
||||
# send_email_control.increment!
|
||||
rescue Exception => e
|
||||
logger_error(e)
|
||||
tip_exception(-2,"邮件发送失败,请稍后重试")
|
||||
|
||||
Reference in New Issue
Block a user