Search code examples
ruby-on-railsdevisedevise-recoverable

Is it possible limit the number of emails sent for devise recoverable in a period of time for each user?


Is it possible limit the number of emials sent for devise recoverable in a period of time for each user? How can I defend against malicious requests?


Solution

  • To limit: "emials sent for devise recoverable"

    Example Gemfile:

    gem 'simple_captcha2'
    

    routes:

    devise_for :users, :controllers => { ..., :passwords => 'passwords', ... }
    

    app/controllers/passwords_controller.rb:

    class PasswordsController < Devise::PasswordsController
    prepend_before_action :require_no_authentication
    #
    # GET /resource/password/new
    def create
        if simple_captcha_valid?
            super
        else
            ....
        end
    end
    

    end

    app/views/devise/passwords/new.html.erb into the form_for:

    <%= show_simple_captcha %>