Sha256: 13178ecffef577d7a6f8e6f24c944e809510431bc5189139ce4cefef369929fd

Contents?: true

Size: 798 Bytes

Versions: 3

Compression:

Stored size: 798 Bytes

Contents

module Apress
  module Api
    module ApiController
      module Authentification
        extend ActiveSupport::Concern

        included do
          attr_reader :current_api_client

          if (Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR == 2) || Rails::VERSION::MAJOR > 4
            before_action :find_session
            before_action :authenticate
          else
            before_filter :find_session
            before_filter :authenticate
          end
        end

        private

        def find_session
          auth_service = AuthService.new(request)
          return unless auth_service.call
          @current_api_client = auth_service.client
        end

        def authenticate
          forbidden unless @current_api_client
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
apress-api-1.23.0 lib/apress/api/api_controller/authentification.rb
apress-api-1.22.1 lib/apress/api/api_controller/authentification.rb
apress-api-1.22.0 lib/apress/api/api_controller/authentification.rb