Sha256: a728e3576c375205728ed43fbe5e9c85e9effa498af69482d8d49e050ef5ed4a

Contents?: true

Size: 1.69 KB

Versions: 12

Compression:

Stored size: 1.69 KB

Contents

module DeviseAuthy
  module Views
    module Helpers
      def authy_request_phone_call_link(opts = {})
        title = opts.delete(:title) do
          I18n.t('request_phone_call', { :scope => 'devise' })
        end
        opts = {
          :id => "authy-request-phone-call-link",
          :method => :post,
          :remote => true
        }.merge(opts)

        link_to(
          title,
          url_for([resource_name, :request_phone_call]),
          opts
        )
      end

      def authy_request_sms_link(opts = {})
        title = opts.delete(:title) do
          I18n.t('request_sms', scope: 'devise')
        end
        opts = {
          :id => "authy-request-sms-link",
          :method => :post,
          :remote => true
        }.merge(opts)

        link_to(
          title,
          url_for([resource_name, :request_sms]),
          opts
        )
      end

      def verify_authy_form(opts = {}, &block)
        opts = default_opts.merge(:id => 'devise_authy').merge(opts)
        form_tag([resource_name, :verify_authy], opts) do
          buffer = hidden_field_tag(:"#{resource_name}_id", @resource.id)
          buffer << capture(&block)
        end
      end

      def enable_authy_form(opts = {}, &block)
        opts = default_opts.merge(opts)
        form_tag([resource_name, :enable_authy], opts) do
          capture(&block)
        end
      end

      def verify_authy_installation_form(opts = {}, &block)
        opts = default_opts.merge(opts)
        form_tag([resource_name, :verify_authy_installation], opts) do
          capture(&block)
        end
      end

      private

      def default_opts
        { :class => 'authy-form', :method => :post }
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
devise-authy-2.2.1 lib/devise-authy/controllers/view_helpers.rb
devise-authy-2.2.0 lib/devise-authy/controllers/view_helpers.rb
devise-authy-2.1.0 lib/devise-authy/controllers/view_helpers.rb
devise-authy-2.0.0 lib/devise-authy/controllers/view_helpers.rb
devise-authy-1.11.1 lib/devise-authy/controllers/view_helpers.rb
devise-authy-1.11.0 lib/devise-authy/controllers/view_helpers.rb
devise-authy-1.10.0 lib/devise-authy/controllers/view_helpers.rb
devise-authy-1.9.0 lib/devise-authy/controllers/view_helpers.rb
devise-authy-1.8.3 lib/devise-authy/controllers/view_helpers.rb
devise-authy-1.8.2 lib/devise-authy/controllers/view_helpers.rb
devise-authy-1.8.1 lib/devise-authy/controllers/view_helpers.rb
devise-authy-1.8.0 lib/devise-authy/controllers/view_helpers.rb