Sha256: 1ce3e184d900f7fb4147b092b9cbe2f5f55e808b49c42c48ba33f179b34fc2f2

Contents?: true

Size: 640 Bytes

Versions: 26

Compression:

Stored size: 640 Bytes

Contents

# frozen_string_literal: true

require 'active_support'

module LHS
  module OAuth
    extend ActiveSupport::Concern

    included do
      prepend_before_action :lhs_store_oauth_access_token
    end

    private

    def lhs_store_oauth_access_token
      lhs_check_auto_oauth_enabled!
      LHS::Interceptors::AutoOauth::ThreadRegistry.access_token = instance_exec(&LHS.config.auto_oauth)
    end

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

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
lhs-22.1.1.pre lib/lhs/concerns/o_auth.rb
lhs-22.1.0 lib/lhs/concerns/o_auth.rb
lhs-22.0.0 lib/lhs/concerns/o_auth.rb
lhs-21.3.1 lib/lhs/concerns/o_auth.rb
lhs-21.3.0 lib/lhs/concerns/o_auth.rb
lhs-21.3.0.pre.autoauth.1 lib/lhs/concerns/o_auth.rb