Class: Doorkeeper::OAuth::CodeRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/doorkeeper/oauth/code_request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pre_auth, resource_owner) ⇒ CodeRequest

Returns a new instance of CodeRequest.


6
7
8
9
10
# File 'lib/doorkeeper/oauth/code_request.rb', line 6

def initialize(pre_auth, resource_owner)
  @pre_auth       = pre_auth
  @client         = pre_auth.client
  @resource_owner = resource_owner
end

Instance Attribute Details

#clientObject

Returns the value of attribute client


4
5
6
# File 'lib/doorkeeper/oauth/code_request.rb', line 4

def client
  @client
end

#pre_authObject

Returns the value of attribute pre_auth


4
5
6
# File 'lib/doorkeeper/oauth/code_request.rb', line 4

def pre_auth
  @pre_auth
end

#resource_ownerObject

Returns the value of attribute resource_owner


4
5
6
# File 'lib/doorkeeper/oauth/code_request.rb', line 4

def resource_owner
  @resource_owner
end

Instance Method Details

#authorizeObject


12
13
14
15
16
17
18
19
20
# File 'lib/doorkeeper/oauth/code_request.rb', line 12

def authorize
  if pre_auth.authorizable?
    auth = Authorization::Code.new(pre_auth, resource_owner)
    auth.issue_token
    @response = CodeResponse.new pre_auth, auth
  else
    @response = ErrorResponse.from_request pre_auth
  end
end

#denyObject


22
23
24
25
26
# File 'lib/doorkeeper/oauth/code_request.rb', line 22

def deny
  pre_auth.error = :access_denied
  ErrorResponse.from_request pre_auth,
                             redirect_uri: pre_auth.redirect_uri
end