Sha256: fe2456d60a9a8a248e575cf514d17ab2b07470d6391c6b14c20beefdd292fac4

Contents?: true

Size: 756 Bytes

Versions: 2

Compression:

Stored size: 756 Bytes

Contents

module Captcher
  module CaptchaAware
    extend ActiveSupport::Concern

    def load_captcha
      Captcher.captcha_class.restore_or_create(Captcher.config, session)
    end

    def reload_captcha
      captcha = Captcher.captcha_class.new(config: Captcher.config)
      captcha.store(session)
      captcha
    end

    def confirm_captcha(confirmation)
      captcha = load_captcha
      captcha.validate(confirmation)
    end
    alias confirm_captcha? confirm_captcha

    private

    def render_captcha(captcha)
      format = params[:format] || captcha.own_config[:format]
      filename = "captcha.#{format}"
      type = "image/#{format}"
      send_data captcha.represent, filename: filename, type: type, disposition: :inline
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
captcher-0.3.1 app/controllers/concerns/captcher/captcha_aware.rb
captcher-0.3.0 app/controllers/concerns/captcher/captcha_aware.rb