A
A
Anton Misyagin2015-06-06 11:49:42
Ruby on Rails
Anton Misyagin, 2015-06-06 11:49:42

How to insert recaptcha into email confirmation?

rails 4.2.1, devise 3.5.1, recaptcha 0.4.0
Managed to embed recaptcha in user registration:

/app/controllers/users/registrations_controller.rb:

class Users::RegistrationsController < Devise::RegistrationsController
  # POST /resource
  def create
    if verify_recaptcha
      super
    else
      build_resource(sign_up_params)
      clean_up_passwords(resource)
      flash.now[:alert] = "Ошибка в коде с картинки."
      flash.delete :recaptcha_error
      render :new
    end
  end
end

Works as it should. Does not create a user until the captcha is entered
. Now, in confirmation:
/app/controllers/users/confirmations_controller.rb:

class Users::ConfirmationsController < Devise::ConfirmationsController
  # POST /resource/confirmation
  def create
    if verify_recaptcha
      super
    else
      flash.now[:alert] = "Ошибка в коде с картинки."
      		flash.delete :recaptcha_error
      		render :new
    end
  end
end

Doesn't respond to recaptcha. Updates the token in the database and sends a letter. Can you help?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Misyagin, 2015-06-06
@sunnmas

Forgot)

devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks", 
    :registrations => "users/registrations", 
    :confirmations => "users/confirmations" }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question