module Doorkeeper::Helpers::Controller

Rails controller helpers.

Private Instance Methods

authenticate_admin!() click to toggle source
# File lib/doorkeeper/helpers/controller.rb, line 31
def authenticate_admin!
  instance_eval(&Doorkeeper.config.authenticate_admin)
end
authenticate_resource_owner!() click to toggle source
# File lib/doorkeeper/helpers/controller.rb, line 13
def authenticate_resource_owner!
  current_resource_owner
end
config_methods() click to toggle source
# File lib/doorkeeper/helpers/controller.rb, line 46
def config_methods
  @config_methods ||= Doorkeeper.config.access_token_methods
end
current_resource_owner() click to toggle source
# File lib/doorkeeper/helpers/controller.rb, line 18
def current_resource_owner
  return @current_resource_owner if defined?(@current_resource_owner)

  @current_resource_owner ||= begin
    instance_eval(&Doorkeeper.config.authenticate_resource_owner)
  end
end
doorkeeper_token() click to toggle source
# File lib/doorkeeper/helpers/controller.rb, line 40
def doorkeeper_token
  return @doorkeeper_token if defined?(@doorkeeper_token)

  @doorkeeper_token ||= OAuth::Token.authenticate(request, *config_methods)
end
enforce_content_type() click to toggle source
# File lib/doorkeeper/helpers/controller.rb, line 78
def enforce_content_type
  if (request.put? || request.post? || request.patch?) && !x_www_form_urlencoded?
    render json: {}, status: :unsupported_media_type
  end
end
get_error_response_from_exception(exception) click to toggle source
# File lib/doorkeeper/helpers/controller.rb, line 50
def get_error_response_from_exception(exception)
  if exception.respond_to?(:response)
    exception.response
  elsif exception.type == :invalid_request
    OAuth::InvalidRequestResponse.new(
      name: exception.type,
      state: params[:state],
      missing_param: exception.missing_param,
    )
  else
    OAuth::ErrorResponse.new(name: exception.type, state: params[:state])
  end
end
handle_token_exception(exception) click to toggle source
# File lib/doorkeeper/helpers/controller.rb, line 64
def handle_token_exception(exception)
  error = get_error_response_from_exception(exception)
  headers.merge!(error.headers)
  self.response_body = error.body.to_json
  self.status = error.status
end
resource_owner_from_credentials() click to toggle source
# File lib/doorkeeper/helpers/controller.rb, line 26
def resource_owner_from_credentials
  instance_eval(&Doorkeeper.config.resource_owner_from_credentials)
end
server() click to toggle source
# File lib/doorkeeper/helpers/controller.rb, line 35
def server
  @server ||= Server.new(self)
end
skip_authorization?() click to toggle source
# File lib/doorkeeper/helpers/controller.rb, line 71
def skip_authorization?
  !!instance_exec(
    [server.current_resource_owner, @pre_auth.client],
    &Doorkeeper.config.skip_authorization
  )
end
x_www_form_urlencoded?() click to toggle source
# File lib/doorkeeper/helpers/controller.rb, line 84
def x_www_form_urlencoded?
  request.media_type == "application/x-www-form-urlencoded"
end