如果电子邮件不在数据库中,则设计阻止确认

时间:2018-09-09 15:55:16

标签: ruby-on-rails-5 devise-confirmable

我正在设计运行Rails 5应用程序。在收到来自俄罗斯对该网站的点击后,最近收到了许多关于虚假电子邮件的确认请求。我认为这是一个机器人,因为我已经收到了这些电子邮件的所有无法传递的电子邮件通知。

如果数据库中没有该用户电子邮件的记录,该如何阻止电子邮件发送出去?

每个请求的摘要片段...

users / beengie / .rvm / gems / ruby​​-2.5.1 / devise / ... confirmations_controller.rb

# POST /resource/confirmation
def create
  self.resource = resource_class.send_confirmation_instructions(resource_params)
  yield resource if block_given?

  if successfully_sent?(resource)
    respond_with({}, location: after_resending_confirmation_instructions_path_for(resource_name))
  else
    respond_with(resource)
  end
end

我尝试包装该方法以防止出现这种情况。仍然不知道它是否还在工作。

app / controllers / users / confirmation_controller.rb

# POST /resource/confirmation
def create
  if User.exists?(email: params[:user][:email])
    super
  end
end

0 个答案:

没有答案
相关问题