Sha256: ccb2540030ae2d8e16bfab4265a41e7b3a8a8f93be3d5b5ac382c94c85f3665f

Contents?: true

Size: 586 Bytes

Versions: 5

Compression:

Stored size: 586 Bytes

Contents

require 'recaptcha'

class RadCaptchaFilter

  def initialize controller
    @controller = controller
  end

  def self.before controller
    RadCaptchaFilter.new(controller).verify
  end

  def verify
    unless verify_captcha
      @controller.send :head, :bad_request, :ErrorMsg => "The security code that you entered does not match the one in the image. Please enter the security code again."
    end
  end

  private

  def verify_captcha
    @controller.extend Recaptcha::Verify
    @controller.verify_recaptcha(:private_key => Rails.configuration.captcha_private_key)
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
trusty-rad-social-extension-2.2.4 app/controllers/rad_captcha_filter.rb
trusty-rad-social-extension-2.2.3 app/controllers/rad_captcha_filter.rb
trusty-rad-social-extension-2.2.2 app/controllers/rad_captcha_filter.rb
trusty-rad-social-extension-2.2.1 app/controllers/rad_captcha_filter.rb
trusty-rad-social-extension-2.2.0 app/controllers/rad_captcha_filter.rb