Module: CommandTower::Execution::IdentityEnrichment

Defined in:
lib/command_tower/execution.rb

Class Method Summary collapse

Class Method Details

.from_impersonation_session(session, actor:, target:) ⇒ Object



60
61
62
63
64
65
66
# File 'lib/command_tower/execution.rb', line 60

def from_impersonation_session(session, actor:, target:)
  CommandTower::Current.user_id = target.id
  CommandTower::Current.effective_user_id = target.id
  CommandTower::Current.originating_administrator_id = actor.id
  CommandTower::Current.impersonation_active = true
  CommandTower::Current.impersonation_session_id = session.id
end

.from_user(user) ⇒ Object



50
51
52
53
54
55
56
57
58
# File 'lib/command_tower/execution.rb', line 50

def from_user(user)
  return if user.nil?

  CommandTower::Current.user_id = user.id
  CommandTower::Current.effective_user_id = user.id
  CommandTower::Current.originating_administrator_id = nil
  CommandTower::Current.impersonation_active = false
  CommandTower::Current.impersonation_session_id = nil
end