Class: Doorkeeper::OAuth::InvalidRequestResponse

Inherits:
ErrorResponse show all
Defined in:
lib/doorkeeper/oauth/invalid_request_response.rb

Constant Summary

Constants inherited from ErrorResponse

ErrorResponse::NON_REDIRECTABLE_STATES

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ErrorResponse

#body, #headers, #raise_exception!, #redirect_uri

Methods inherited from BaseResponse

#body, #headers, #redirect_uri

Constructor Details

#initialize(attributes = {}) ⇒ InvalidRequestResponse

Returns a new instance of InvalidRequestResponse.



19
20
21
22
23
# File 'lib/doorkeeper/oauth/invalid_request_response.rb', line 19

def initialize(attributes = {})
  super(attributes.merge(name: :invalid_request))
  @missing_param = attributes[:missing_param]
  @reason = @missing_param.nil? ? attributes[:reason] : :missing_param
end

Instance Attribute Details

#reasonObject (readonly)

Returns the value of attribute reason.



6
7
8
# File 'lib/doorkeeper/oauth/invalid_request_response.rb', line 6

def reason
  @reason
end

Class Method Details

.from_request(request, attributes = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/doorkeeper/oauth/invalid_request_response.rb', line 8

def self.from_request(request, attributes = {})
  new(
    attributes.merge(
      state: request.try(:state),
      redirect_uri: request.try(:redirect_uri),
      missing_param: request.try(:missing_param),
      reason: request.try(:invalid_request_reason),
    ),
  )
end

Instance Method Details

#descriptionObject



29
30
31
32
33
34
35
36
# File 'lib/doorkeeper/oauth/invalid_request_response.rb', line 29

def description
  I18n.translate(
    reason,
    scope: %i[doorkeeper errors messages invalid_request],
    default: :unknown,
    value: @missing_param,
  )
end

#exception_classObject



38
39
40
# File 'lib/doorkeeper/oauth/invalid_request_response.rb', line 38

def exception_class
  Doorkeeper::Errors::InvalidRequest
end

#redirectable?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/doorkeeper/oauth/invalid_request_response.rb', line 42

def redirectable?
  super && @missing_param != :client_id
end

#statusObject



25
26
27
# File 'lib/doorkeeper/oauth/invalid_request_response.rb', line 25

def status
  :bad_request
end