Class: Actions::Middleware::KeepCurrentUser

Inherits:
Dynflow::Middleware
  • Object
show all
Defined in:
app/lib/actions/middleware/keep_current_user.rb

Instance Method Summary collapse

Instance Method Details

#delay(*args) ⇒ Object



4
5
6
# File 'app/lib/actions/middleware/keep_current_user.rb', line 4

def delay(*args)
  pass(*args).tap { store_current_user }
end

#finalizeObject



18
19
20
21
22
23
24
25
26
# File 'app/lib/actions/middleware/keep_current_user.rb', line 18

def finalize
  current_id = User.current.try(:id)
  saved_id = action.input[:current_user_id]
  if User.current && saved_id && current_id != saved_id
    Foreman::Deprecation.deprecation_warning('2.5', 'relying on per-step setting of current user in finalize phase')
  end

  restore_curent_user { pass }
end

#finalize_phase(execution_plan, *args) ⇒ Object



28
29
30
# File 'app/lib/actions/middleware/keep_current_user.rb', line 28

def finalize_phase(execution_plan, *args)
  restore_curent_user(execution_plan.entry_action) { pass(execution_plan, *args) }
end

#hook(*args) ⇒ Object

Run all execution plan lifecycle hooks as the original user



33
34
35
# File 'app/lib/actions/middleware/keep_current_user.rb', line 33

def hook(*args)
  restore_curent_user { pass(*args) }
end

#plan(*args) ⇒ Object



8
9
10
11
12
# File 'app/lib/actions/middleware/keep_current_user.rb', line 8

def plan(*args)
  with_current_user do
    pass(*args).tap { store_current_user }
  end
end

#run(*args) ⇒ Object



14
15
16
# File 'app/lib/actions/middleware/keep_current_user.rb', line 14

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