Module: Redmine::SudoMode::Controller::ClassMethods

Defined in:
lib/redmine/sudo_mode.rb

Instance Method Summary collapse

Instance Method Details

#require_sudo_mode(*args) ⇒ Object

Handles sudo requirements for the given actions, preserving the named parameters, or any parameters if you omit the :parameters option.

Sudo enforcement by default is active for all requests to an action but may be limited to a certain subset of request methods via the :only option.

Examples:

require_sudo_mode :account, only: :post require_sudo_mode :update, :create, parameters: %w(role) require_sudo_mode :destroy



167
168
169
170
171
172
# File 'lib/redmine/sudo_mode.rb', line 167

def require_sudo_mode(*args)
  actions = args.dup
  options = actions.extract_options!
  filter = SudoRequestFilter.new Array(options[:parameters]), Array(options[:only])
  before_action filter, only: actions
end