Sha256: 068b8ccd47efee259b4022428a2339ed91b0965f7b46be5aedb9f248457716e5

Contents?: true

Size: 1.06 KB

Versions: 5

Compression:

Stored size: 1.06 KB

Contents

# frozen_string_literal: true

module Doorkeeper
  module OAuth
    class CodeResponse < BaseResponse
      include OAuth::Helpers

      attr_accessor :pre_auth, :auth, :response_on_fragment

      def initialize(pre_auth, auth, options = {})
        @pre_auth = pre_auth
        @auth = auth
        @response_on_fragment = options[:response_on_fragment]
      end

      def redirectable?
        true
      end

      def redirect_uri
        if URIChecker.native_uri? pre_auth.redirect_uri
          auth.native_redirect
        elsif response_on_fragment
          Authorization::URIBuilder.uri_with_fragment(
            pre_auth.redirect_uri,
            access_token: auth.token.plaintext_token,
            token_type: auth.token.token_type,
            expires_in: auth.token.expires_in_seconds,
            state: pre_auth.state
          )
        else
          Authorization::URIBuilder.uri_with_query(
            pre_auth.redirect_uri,
            code: auth.token.plaintext_token,
            state: pre_auth.state
          )
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
doorkeeper-5.1.2 lib/doorkeeper/oauth/code_response.rb
doorkeeper-5.1.1 lib/doorkeeper/oauth/code_response.rb
doorkeeper-5.1.0 lib/doorkeeper/oauth/code_response.rb
doorkeeper-5.1.0.rc2 lib/doorkeeper/oauth/code_response.rb
doorkeeper-5.1.0.rc1 lib/doorkeeper/oauth/code_response.rb