Sha256: f76cdc08646d484f3de88332698b857dd3af28990e48e8c83e2f0a665cb050e5

Contents?: true

Size: 1.03 KB

Versions: 244

Compression:

Stored size: 1.03 KB

Contents

module Actions
  module Middleware
    # Helpers for remote actions
    # wraps the plan/run/finalize methods to include the info about the user
    # that triggered the action.
    class RemoteAction < Dynflow::Middleware
      def plan(*args)
        fail "No current user is set. Please set User.current to perform a remote action" if User.current.nil?
        pass(*args).tap do
          action.input[:remote_user] = User.remote_user
          action.input[:remote_cp_user] = User.remote_user
        end
      end

      def run(*args)
        as_remote_user { pass(*args) }
      end

      def finalize
        as_remote_user { pass }
      end

      private

      def as_cp_user(&block)
        fail 'missing :remote_user' unless cp_user
        ::User.cp_config('cp-user' => cp_user, &block)
      end

      def remote_user
        action.input[:remote_user]
      end

      def cp_user
        action.input[:remote_cp_user]
      end

      def as_remote_user
        as_cp_user do
          yield
        end
      end
    end
  end
end

Version data entries

244 entries across 244 versions & 1 rubygems

Version Path
katello-4.16.0 app/lib/actions/middleware/remote_action.rb
katello-4.15.1 app/lib/actions/middleware/remote_action.rb
katello-4.16.0.rc2 app/lib/actions/middleware/remote_action.rb
katello-4.16.0.rc1 app/lib/actions/middleware/remote_action.rb
katello-4.14.3 app/lib/actions/middleware/remote_action.rb
katello-4.14.2 app/lib/actions/middleware/remote_action.rb
katello-4.15.0 app/lib/actions/middleware/remote_action.rb
katello-4.15.0.rc2 app/lib/actions/middleware/remote_action.rb
katello-4.15.0.rc1 app/lib/actions/middleware/remote_action.rb
katello-4.14.1 app/lib/actions/middleware/remote_action.rb
katello-4.14.0 app/lib/actions/middleware/remote_action.rb
katello-4.14.0.rc3 app/lib/actions/middleware/remote_action.rb
katello-4.14.0.rc2 app/lib/actions/middleware/remote_action.rb
katello-4.14.0.rc1.1 app/lib/actions/middleware/remote_action.rb
katello-4.14.0.rc1 app/lib/actions/middleware/remote_action.rb
katello-4.13.1 app/lib/actions/middleware/remote_action.rb
katello-4.13.0 app/lib/actions/middleware/remote_action.rb
katello-4.12.1 app/lib/actions/middleware/remote_action.rb
katello-4.13.0.rc1 app/lib/actions/middleware/remote_action.rb
katello-4.12.0 app/lib/actions/middleware/remote_action.rb