Module: Doorkeeper::Helpers::Controller
- Included in:
- ApplicationController, TokensController
- Defined in:
- lib/doorkeeper/helpers/controller.rb
Class Method Summary collapse
Instance Method Summary collapse
- #authenticate_admin! ⇒ Object
- #authenticate_resource_owner! ⇒ Object
- #current_resource_owner ⇒ Object
- #get_error_response_from_exception(exception) ⇒ Object
- #handle_token_exception(exception) ⇒ Object
- #resource_owner_from_credentials ⇒ Object
- #server ⇒ Object
- #skip_authorization? ⇒ Boolean
Class Method Details
.included(base) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/doorkeeper/helpers/controller.rb', line 4 def self.included(base) base.send :private, :authenticate_resource_owner!, :authenticate_admin!, :current_resource_owner, :resource_owner_from_credentials, :skip_authorization? end |
Instance Method Details
#authenticate_admin! ⇒ Object
25 26 27 |
# File 'lib/doorkeeper/helpers/controller.rb', line 25 def authenticate_admin! instance_eval &Doorkeeper.configuration.authenticate_admin end |
#authenticate_resource_owner! ⇒ Object
13 14 15 |
# File 'lib/doorkeeper/helpers/controller.rb', line 13 def authenticate_resource_owner! current_resource_owner end |
#current_resource_owner ⇒ Object
17 18 19 |
# File 'lib/doorkeeper/helpers/controller.rb', line 17 def current_resource_owner instance_eval &Doorkeeper.configuration.authenticate_resource_owner end |
#get_error_response_from_exception(exception) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/doorkeeper/helpers/controller.rb', line 33 def get_error_response_from_exception(exception) error_name = case exception when Errors::InvalidTokenStrategy :unsupported_grant_type when Errors::InvalidAuthorizationStrategy :unsupported_response_type when Errors::MissingRequestStrategy :invalid_request end OAuth::ErrorResponse.new :name => error_name, :state => params[:state] end |
#handle_token_exception(exception) ⇒ Object
46 47 48 49 50 51 |
# File 'lib/doorkeeper/helpers/controller.rb', line 46 def handle_token_exception(exception) error = get_error_response_from_exception exception self.headers.merge! error.headers self.response_body = error.body.to_json self.status = error.status end |
#resource_owner_from_credentials ⇒ Object
21 22 23 |
# File 'lib/doorkeeper/helpers/controller.rb', line 21 def resource_owner_from_credentials instance_eval &Doorkeeper.configuration.resource_owner_from_credentials end |
#server ⇒ Object
29 30 31 |
# File 'lib/doorkeeper/helpers/controller.rb', line 29 def server @server ||= Server.new(self) end |
#skip_authorization? ⇒ Boolean
53 54 55 |
# File 'lib/doorkeeper/helpers/controller.rb', line 53 def !!instance_exec([@server.current_resource_owner, @pre_auth.client], &Doorkeeper.configuration.) end |