Sha256: 5353770c6035a99924be2b505ec6d867ff40137cd73c9e6c6d4454dd93e5bf23

Contents?: true

Size: 792 Bytes

Versions: 4

Compression:

Stored size: 792 Bytes

Contents

module Captcher
  module CaptchaAware
    extend ActiveSupport::Concern

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

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

    def confirm_captcha(session, confirmation)
      captcha = load_captcha(session)
      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

4 entries across 4 versions & 1 rubygems

Version Path
captcher-0.2.1 app/controllers/concerns/captcher/captcha_aware.rb
captcher-0.2.0 app/controllers/concerns/captcher/captcha_aware.rb
captcher-0.1.1 app/controllers/concerns/captcher/captcha_aware.rb
captcher-0.1.0 app/controllers/concerns/captcher/captcha_aware.rb