Sha256: 6406a10256d159e97dcae4ad68af6d2e712f1e288aa5622fae8203c15f68c87e

Contents?: true

Size: 626 Bytes

Versions: 12

Compression:

Stored size: 626 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 current_user current_resource_owner
  
  protected
  def anonymous_action?
    false
  end
  <% else %>
  def current_user
    nil
  end
  <% end %>
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
mobile_workflow-0.12.2 lib/generators/mobile_workflow/install/templates/api_controller.rb.erb
mobile_workflow-0.12.1 lib/generators/mobile_workflow/install/templates/api_controller.rb.erb
mobile_workflow-0.12.0 lib/generators/mobile_workflow/install/templates/api_controller.rb.erb
mobile_workflow-0.11.1 lib/generators/mobile_workflow/install/templates/api_controller.rb.erb
mobile_workflow-0.11.0 lib/generators/mobile_workflow/install/templates/api_controller.rb.erb
mobile_workflow-0.10.2 lib/generators/mobile_workflow/install/templates/api_controller.rb.erb
mobile_workflow-0.10.1 lib/generators/mobile_workflow/install/templates/api_controller.rb.erb
mobile_workflow-0.10.0 lib/generators/mobile_workflow/install/templates/api_controller.rb.erb
mobile_workflow-0.9.0 lib/generators/mobile_workflow/install/templates/api_controller.rb.erb
mobile_workflow-0.8.9 lib/generators/mobile_workflow/install/templates/api_controller.rb.erb
mobile_workflow-0.7.9 lib/generators/mobile_workflow/install/templates/api_controller.rb.erb
mobile_workflow-0.7.8 lib/generators/mobile_workflow/install/templates/api_controller.rb.erb