foreman-tasks 0.6.7 → 0.6.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -17,7 +17,7 @@ module Actions
17
17
  def run
18
18
  ::User.as :admin do
19
19
  host = ::Host.find(input[:host][:id])
20
- state = host.importFacts(input[:facts])
20
+ state = host.import_facts(input[:facts])
21
21
  output[:state] = state
22
22
  end
23
23
  rescue ::Foreman::Exception => e
@@ -73,6 +73,7 @@ module ForemanTasks
73
73
  end
74
74
 
75
75
  def self.search_by_generic_resource(key, operator, value)
76
+ key = "resource_type" if key.blank?
76
77
  key_name = self.connection.quote_column_name(key.sub(/^.*\./,''))
77
78
  condition = sanitize_sql_for_conditions(["foreman_tasks_locks.#{key_name} #{operator} ?", value])
78
79
 
@@ -89,7 +90,12 @@ module ForemanTasks
89
90
  INNER JOIN users
90
91
  ON (users.id = foreman_tasks_locks_owner.resource_id)
91
92
  JOINS
92
- condition = sanitize_sql_for_conditions(["users.#{key_name} #{operator} ?", value])
93
+
94
+ condition = if key.blank?
95
+ sanitize_sql_for_conditions(["users.login #{operator} ? or users.firstname #{operator} ? ", value, value])
96
+ else
97
+ sanitize_sql_for_conditions(["users.#{key_name} #{operator} ?", value])
98
+ end
93
99
  return {:conditions => condition, :joins => joins }
94
100
  end
95
101
 
@@ -6,7 +6,8 @@ class Setting::ForemanTasks < Setting
6
6
 
7
7
  self.transaction do
8
8
  [
9
- self.set('dynflow_enable_console', N_("Enable the dynflow console (/foreman_tasks/dynflow) for debugging"), false),
9
+ self.set('dynflow_enable_console', N_("Enable the dynflow console (/foreman_tasks/dynflow) for debugging"), true),
10
+ self.set('dynflow_console_require_auth', N_("Require user to be authenticated as user with admin rights when accessing dynflow console"), true)
10
11
  ].each { |s| self.create! s.update(:category => "Setting::ForemanTasks")}
11
12
  end
12
13
 
@@ -82,7 +82,13 @@ module ForemanTasks
82
82
  def web_console
83
83
  ::Dynflow::WebConsole.setup do
84
84
  before do
85
- if !Setting[:dynflow_enable_console]
85
+ rack_request = Rack::Request.new(env)
86
+ user_id, expires_at = rack_request.session.
87
+ values_at('user', 'expires_at')
88
+ if Setting[:dynflow_console_require_auth] &&
89
+ (!Setting[:dynflow_enable_console] ||
90
+ (user_id.nil? || !User.find(user_id).admin) ||
91
+ Time.now.to_i > expires_at)
86
92
  redirect('dashboard')
87
93
  end
88
94
  end
@@ -1,3 +1,3 @@
1
1
  module ForemanTasks
2
- VERSION = "0.6.7"
2
+ VERSION = "0.6.8"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman-tasks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.7
4
+ version: 0.6.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-08-06 00:00:00.000000000 Z
12
+ date: 2014-08-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails