Sha256: 31d261a1ebb69f384b5d32aee1cba88c6693fb7402f2f28fb5191956a316636d

Contents?: true

Size: 640 Bytes

Versions: 12

Compression:

Stored size: 640 Bytes

Contents

# frozen_string_literal: true

require 'active_support'

module DHS
  module OAuth
    extend ActiveSupport::Concern

    included do
      prepend_before_action :dhs_store_oauth_access_token
    end

    private

    def dhs_store_oauth_access_token
      dhs_check_auto_oauth_enabled!
      DHS::Interceptors::AutoOauth::ThreadRegistry.access_token = instance_exec(&DHS.config.auto_oauth)
    end

    def dhs_check_auto_oauth_enabled!
      return if DHS.config.auto_oauth.present? && DHS.config.auto_oauth.is_a?(Proc)
      raise 'You have to enable DHS.config.auto_oauth by passing a proc returning an access token!'
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
dhs-1.6.0 lib/dhs/concerns/o_auth.rb
dhs-1.5.0 lib/dhs/concerns/o_auth.rb
dhs-1.4.2 lib/dhs/concerns/o_auth.rb
dhs-1.4.1 lib/dhs/concerns/o_auth.rb
dhs-1.4.0 lib/dhs/concerns/o_auth.rb
dhs-1.3.0 lib/dhs/concerns/o_auth.rb
dhs-1.2.0 lib/dhs/concerns/o_auth.rb
dhs-1.1.0 lib/dhs/concerns/o_auth.rb
dhs-1.0.3 lib/dhs/concerns/o_auth.rb
dhs-1.0.2 lib/dhs/concerns/o_auth.rb
dhs-1.0.1 lib/dhs/concerns/o_auth.rb
dhs-1.0.0 lib/dhs/concerns/o_auth.rb