Sha256: 34ff926c919b738ccac6482cf9d89b0a0990ff11bcd5e9c971203bb372732d74

Contents?: true

Size: 636 Bytes

Versions: 43

Compression:

Stored size: 636 Bytes

Contents

class ApiController < ActionController::API
  rescue_from CanCan::AccessDenied do |exception|
    Rails.logger.debug "Access denied on #{exception.action} #{exception.subject.inspect}"
    head :forbidden
  end

  <% if options[:doorkeeper_oauth] %>
  before_action :doorkeeper_authorize!, unless: :anonymous_action?
  
  def current_resource_owner
    @current_resource_owner ||= User.find(doorkeeper_token.resource_owner_id) if doorkeeper_token&.accessible?
  end
  alias_method :current_user, :current_resource_owner
  
  protected
  def anonymous_action?
    false
  end
  <% else %>
  def current_user
    nil
  end
  <% end %>
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
mobile_workflow-0.6.19 lib/generators/mobile_workflow/install/templates/api_controller.rb.erb
mobile_workflow-0.6.18 lib/generators/mobile_workflow/install/templates/api_controller.rb.erb
mobile_workflow-0.6.17 lib/generators/mobile_workflow/install/templates/api_controller.rb.erb
mobile_workflow-0.6.16 lib/generators/mobile_workflow/install/templates/api_controller.rb.erb
mobile_workflow-0.6.15 lib/generators/mobile_workflow/install/templates/api_controller.rb.erb
mobile_workflow-0.6.14 lib/generators/mobile_workflow/install/templates/api_controller.rb.erb
mobile_workflow-0.6.13 lib/generators/mobile_workflow/install/templates/api_controller.rb.erb
mobile_workflow-0.6.12 lib/generators/mobile_workflow/install/templates/api_controller.rb.erb
mobile_workflow-0.6.11 lib/generators/mobile_workflow/install/templates/api_controller.rb.erb
mobile_workflow-0.6.10 lib/generators/mobile_workflow/install/templates/api_controller.rb.erb
mobile_workflow-0.6.9 lib/generators/mobile_workflow/install/templates/api_controller.rb.erb
mobile_workflow-0.6.8 lib/generators/mobile_workflow/install/templates/api_controller.rb.erb
mobile_workflow-0.6.7 lib/generators/mobile_workflow/install/templates/api_controller.rb.erb
mobile_workflow-0.6.6 lib/generators/mobile_workflow/install/templates/api_controller.rb.erb
mobile_workflow-0.6.4 lib/generators/mobile_workflow/install/templates/api_controller.rb.erb
mobile_workflow-0.6.3 lib/generators/mobile_workflow/install/templates/api_controller.rb.erb
mobile_workflow-0.6.2 lib/generators/mobile_workflow/install/templates/api_controller.rb.erb
mobile_workflow-0.6.1 lib/generators/mobile_workflow/install/templates/api_controller.rb.erb
mobile_workflow-0.6.0 lib/generators/mobile_workflow/install/templates/api_controller.rb.erb
mobile_workflow-0.5.11 lib/generators/mobile_workflow/install/templates/api_controller.rb.erb