Class: Doorkeeper::OAuth::ErrorResponse
Class Method Summary
collapse
Instance Method Summary
collapse
#build_query, #uri_with_fragment, #uri_with_query
Constructor Details
#initialize(attributes = {}) ⇒ ErrorResponse
Returns a new instance of ErrorResponse.
13
14
15
16
17
|
# File 'lib/doorkeeper/oauth/error_response.rb', line 13
def initialize(attributes = {})
@error = Doorkeeper::OAuth::Error.new(*attributes.values_at(:name, :state))
@redirect_uri = attributes[:redirect_uri]
@response_on_fragment = attributes[:response_on_fragment]
end
|
Class Method Details
.from_request(request, attributes = {}) ⇒ Object
6
7
8
9
|
# File 'lib/doorkeeper/oauth/error_response.rb', line 6
def self.from_request(request, attributes = {})
state = request.state if request.respond_to?(:state)
new(attributes.merge(:name => request.error, :state => state))
end
|
Instance Method Details
#body ⇒ Object
19
20
21
|
# File 'lib/doorkeeper/oauth/error_response.rb', line 19
def body
{ :error => name, :error_description => description, :state => state }.reject { |k, v| v.blank? }
end
|
39
40
41
|
# File 'lib/doorkeeper/oauth/error_response.rb', line 39
def
{ 'Cache-Control' => 'no-store', 'Pragma' => 'no-cache', 'Content-Type' => 'application/json; charset=utf-8' }
end
|
#redirect_uri ⇒ Object
31
32
33
34
35
36
37
|
# File 'lib/doorkeeper/oauth/error_response.rb', line 31
def redirect_uri
if @response_on_fragment
uri_with_fragment @redirect_uri, body
else
uri_with_query @redirect_uri, body
end
end
|
#redirectable? ⇒ Boolean
27
28
29
|
# File 'lib/doorkeeper/oauth/error_response.rb', line 27
def redirectable?
(name != :invalid_redirect_uri) && (name != :invalid_client)
end
|
#status ⇒ Object
23
24
25
|
# File 'lib/doorkeeper/oauth/error_response.rb', line 23
def status
:unauthorized
end
|