Module: Foreman::ThreadSession::Cleaner

Extended by:
ActiveSupport::Concern
Included in:
Api::GraphqlController, ApplicationShared
Defined in:
app/models/concerns/foreman/thread_session.rb

Overview

module to be include in controller to clear the session data after (and evenutally before) the request processing. Without it we're risking inter-users interference.

Instance Method Summary collapse

Instance Method Details

#clear_threadObject


27
28
29
30
31
32
33
34
35
36
37
# File 'app/models/concerns/foreman/thread_session.rb', line 27

def clear_thread
  if Thread.current[:user] && !Rails.env.test?
    Foreman::Logging.logger('taxonomy').warn("Current user is set, but not expected. Clearing")
    Thread.current[:user] = nil
  end
  yield
ensure
  [:user, :organization, :location].each do |key|
    Thread.current[key] = nil
  end
end