Sha256: 444c2fa3c6cdc337768db9bd5453e103c0b0a869af46904d3375b25eed2c2d58

Contents?: true

Size: 608 Bytes

Versions: 9

Compression:

Stored size: 608 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
    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

9 entries across 9 versions & 1 rubygems

Version Path
mobile_workflow-0.5.7 lib/generators/mobile_workflow/install/templates/api_controller.rb.erb
mobile_workflow-0.5.6 lib/generators/mobile_workflow/install/templates/api_controller.rb.erb
mobile_workflow-0.5.5 lib/generators/mobile_workflow/install/templates/api_controller.rb.erb
mobile_workflow-0.5.4 lib/generators/mobile_workflow/install/templates/api_controller.rb.erb
mobile_workflow-0.5.3 lib/generators/mobile_workflow/install/templates/api_controller.rb.erb
mobile_workflow-0.5.2 lib/generators/mobile_workflow/install/templates/api_controller.rb.erb
mobile_workflow-0.5.1 lib/generators/mobile_workflow/install/templates/api_controller.rb.erb
mobile_workflow-0.5.0 lib/generators/mobile_workflow/install/templates/api_controller.rb.erb
mobile_workflow-0.4.0 lib/generators/mobile_workflow/install/templates/api_controller.rb.erb