Sha256: 24dff9658249cb8f0552c8517b0780360aad8e60bc600149c843bc5a12d6c30c

Contents?: true

Size: 705 Bytes

Versions: 2

Compression:

Stored size: 705 Bytes

Contents

# This overrides the before method provided by resource_controller so that the current_user is authorized
# for each action before proceding.
module ResourceController
  module Helpers
    module Internal
      protected
        # Calls the before block for the action, if one is present.
        def before(action)

          resource = case action
          when :index, :new, :create
            model
          else object
          end

          if resource.respond_to? :token
            authorize! action, resource, session[:access_token]
          else
            authorize! action, resource
          end
          invoke_callbacks *self.class.send(action).before
        end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spree_auth-1.0.0.rc2 app/controllers/resource_controller_decorator.rb
spree_auth-1.0.0.rc1 app/controllers/resource_controller_decorator.rb