Class: Redmine::SudoMode::Controller::SudoRequestFilter

Inherits:
Struct
  • Object
show all
Defined in:
lib/redmine/sudo_mode.rb

Overview

Before Filter which is used by the require_sudo_mode class method.

Since:

  • 3.1.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#parametersObject

Returns the value of attribute parameters

Returns:

  • (Object)

    the current value of parameters



139
140
141
# File 'lib/redmine/sudo_mode.rb', line 139

def parameters
  @parameters
end

#request_methodsObject

Returns the value of attribute request_methods

Returns:

  • (Object)

    the current value of request_methods



139
140
141
# File 'lib/redmine/sudo_mode.rb', line 139

def request_methods
  @request_methods
end

Instance Method Details

#before(controller) ⇒ Object



140
141
142
143
144
145
146
147
148
149
# File 'lib/redmine/sudo_mode.rb', line 140

def before(controller)
  method_matches = request_methods.blank? || request_methods.include?(controller.request.method_symbol)
  if controller.api_request?
    true
  elsif SudoMode.possible? && method_matches
    controller.require_sudo_mode( *parameters )
  else
    true
  end
end