Sha256: 67b1ed3222f28c5eca472db9b71b1edc425732c61073beaf1120b1e38321c0d6

Contents?: true

Size: 1.08 KB

Versions: 9

Compression:

Stored size: 1.08 KB

Contents

module Doorkeeper
  module OAuth
    module RequestConcern
      def authorize
        validate
        if valid?
          before_successful_response
          @response = TokenResponse.new(access_token)
          after_successful_response
          @response
        else
          @response = ErrorResponse.from_request(self)
        end
      end

      def scopes
        @scopes ||= if @original_scopes.present?
                      OAuth::Scopes.from_string(@original_scopes)
                    else
                      default_scopes
                    end
      end

      def default_scopes
        server.default_scopes
      end

      def valid?
        error.nil?
      end

      def find_or_create_access_token(client, resource_owner_id, scopes, server)
        @access_token = AccessToken.find_or_create_for(
          client,
          resource_owner_id,
          scopes,
          server.access_token_expires_in,
          server.refresh_token_enabled?)
      end

      def before_successful_response
      end

      def after_successful_response
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
doorkeeper-1.4.2 lib/doorkeeper/oauth/request_concern.rb
doorkeeper-2.1.0 lib/doorkeeper/oauth/request_concern.rb
doorkeeper-2.0.1 lib/doorkeeper/oauth/request_concern.rb
doorkeeper-1.4.1 lib/doorkeeper/oauth/request_concern.rb
doorkeeper-2.0.0 lib/doorkeeper/oauth/request_concern.rb
doorkeeper-2.0.0.rc3 lib/doorkeeper/oauth/request_concern.rb
doorkeeper-2.0.0.rc2 lib/doorkeeper/oauth/request_concern.rb
doorkeeper-2.0.0.alpha1 lib/doorkeeper/oauth/request_concern.rb
doorkeeper-1.4.0 lib/doorkeeper/oauth/request_concern.rb