Module: Doorkeeper::OAuth::RequestConcern
- Included in:
- AuthorizationCodeRequest, ClientCredentialsRequest, PasswordAccessTokenRequest, RefreshTokenRequest
- Defined in:
- lib/doorkeeper/oauth/request_concern.rb
Instance Method Summary collapse
- #after_successful_response ⇒ Object
- #authorize ⇒ Object
- #before_successful_response ⇒ Object
- #default_scopes ⇒ Object
- #find_or_create_access_token(client, resource_owner_id, scopes, server) ⇒ Object
- #scopes ⇒ Object
- #valid? ⇒ Boolean
Instance Method Details
#after_successful_response ⇒ Object
44 45 |
# File 'lib/doorkeeper/oauth/request_concern.rb', line 44 def after_successful_response end |
#authorize ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/doorkeeper/oauth/request_concern.rb', line 4 def validate if valid? before_successful_response @response = TokenResponse.new(access_token) after_successful_response @response else @response = ErrorResponse.from_request(self) end end |
#before_successful_response ⇒ Object
41 42 |
# File 'lib/doorkeeper/oauth/request_concern.rb', line 41 def before_successful_response end |
#default_scopes ⇒ Object
24 25 26 |
# File 'lib/doorkeeper/oauth/request_concern.rb', line 24 def default_scopes server.default_scopes end |
#find_or_create_access_token(client, resource_owner_id, scopes, server) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/doorkeeper/oauth/request_concern.rb', line 32 def find_or_create_access_token(client, resource_owner_id, scopes, server) @access_token = AccessToken.find_or_create_for( client, resource_owner_id, scopes, server.access_token_expires_in, server.refresh_token_enabled?) end |
#scopes ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/doorkeeper/oauth/request_concern.rb', line 16 def scopes @scopes ||= if @original_scopes.present? OAuth::Scopes.from_string(@original_scopes) else default_scopes end end |
#valid? ⇒ Boolean
28 29 30 |
# File 'lib/doorkeeper/oauth/request_concern.rb', line 28 def valid? error.nil? end |