Class: CommandTower::Impersonation::Session

Inherits:
ApplicationRecord show all
Defined in:
app/models/command_tower/impersonation/session.rb

Constant Summary collapse

END_REASONS =
%w[manual idle_timeout absolute_timeout logout revoked].freeze

Instance Method Summary collapse

Methods inherited from ApplicationRecord

attribute_to_type_mapping

Instance Method Details

#absolutely_expired?(at: Time.current) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'app/models/command_tower/impersonation/session.rb', line 29

def absolutely_expired?(at: Time.current)
  absolute_expires_at <= at
end

#expiration_reason(at: Time.current) ⇒ Object



37
38
39
40
41
42
# File 'app/models/command_tower/impersonation/session.rb', line 37

def expiration_reason(at: Time.current)
  return "absolute_timeout" if absolutely_expired?(at:)
  return "idle_timeout" if idle_expired?(at:)

  nil
end

#expired?(at: Time.current) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
# File 'app/models/command_tower/impersonation/session.rb', line 33

def expired?(at: Time.current)
  idle_expired?(at:) || absolutely_expired?(at:)
end

#idle_expired?(at: Time.current) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'app/models/command_tower/impersonation/session.rb', line 25

def idle_expired?(at: Time.current)
  idle_expires_at <= at
end

#open?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'app/models/command_tower/impersonation/session.rb', line 21

def open?
  ended_at.nil?
end