Class: Doorkeeper::OAuth::CodeResponse

Inherits:
Object
  • Object
show all
Includes:
Authorization::URIBuilder, Helpers
Defined in:
lib/doorkeeper/oauth/code_response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Authorization::URIBuilder

#build_query, #uri_with_fragment, #uri_with_query

Constructor Details

#initialize(pre_auth, auth, options = {}) ⇒ CodeResponse

Returns a new instance of CodeResponse.



9
10
11
12
# File 'lib/doorkeeper/oauth/code_response.rb', line 9

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

Instance Attribute Details

#authObject

Returns the value of attribute auth.



7
8
9
# File 'lib/doorkeeper/oauth/code_response.rb', line 7

def auth
  @auth
end

#pre_authObject

Returns the value of attribute pre_auth.



7
8
9
# File 'lib/doorkeeper/oauth/code_response.rb', line 7

def pre_auth
  @pre_auth
end

#response_on_fragmentObject

Returns the value of attribute response_on_fragment.



7
8
9
# File 'lib/doorkeeper/oauth/code_response.rb', line 7

def response_on_fragment
  @response_on_fragment
end

Instance Method Details

#redirect_uriObject

TODO: configure the test oauth path?



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/doorkeeper/oauth/code_response.rb', line 19

def redirect_uri
  if URIChecker.test_uri? pre_auth.redirect_uri
    "/oauth/authorize/#{auth.token.token}"
  else
    if response_on_fragment
      uri_with_fragment(pre_auth.redirect_uri, {
        :access_token => auth.token.token,
        :token_type   => auth.token.token_type,
        :expires_in   => auth.token.expires_in,
        :state        => pre_auth.state
      })
    else
      uri_with_query pre_auth.redirect_uri, :code => auth.token.token, :state => pre_auth.state
    end
  end
end

#redirectable?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/doorkeeper/oauth/code_response.rb', line 14

def redirectable?
  true
end