Class: Doorkeeper::OAuth::Authorization::Code

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pre_auth, resource_owner) ⇒ Code

Returns a new instance of Code.


7
8
9
10
# File 'lib/doorkeeper/oauth/authorization/code.rb', line 7

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

Instance Attribute Details

#pre_authObject

Returns the value of attribute pre_auth


5
6
7
# File 'lib/doorkeeper/oauth/authorization/code.rb', line 5

def pre_auth
  @pre_auth
end

#resource_ownerObject

Returns the value of attribute resource_owner


5
6
7
# File 'lib/doorkeeper/oauth/authorization/code.rb', line 5

def resource_owner
  @resource_owner
end

#tokenObject

Returns the value of attribute token


5
6
7
# File 'lib/doorkeeper/oauth/authorization/code.rb', line 5

def token
  @token
end

Instance Method Details

#configurationObject


26
27
28
# File 'lib/doorkeeper/oauth/authorization/code.rb', line 26

def configuration
  Doorkeeper.configuration
end

#issue_tokenObject


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

def issue_token
  @token ||= AccessGrant.create!(
    application_id: pre_auth.client.id,
    resource_owner_id: resource_owner.id,
    expires_in: configuration.authorization_code_expires_in,
    redirect_uri: pre_auth.redirect_uri,
    scopes: pre_auth.scopes.to_s
  )
end

#native_redirectObject


22
23
24
# File 'lib/doorkeeper/oauth/authorization/code.rb', line 22

def native_redirect
  { action: :show, code: token.token }
end