2024-10-03 14:42:22 -04:00
|
|
|
class Session < ApplicationRecord
|
|
|
|
belongs_to :user
|
2024-10-18 11:26:58 -05:00
|
|
|
belongs_to :active_impersonator_session,
|
|
|
|
-> { where(status: :in_progress) },
|
|
|
|
class_name: "ImpersonationSession",
|
|
|
|
optional: true
|
2024-10-03 14:42:22 -04:00
|
|
|
|
|
|
|
before_create do
|
|
|
|
self.user_agent = Current.user_agent
|
|
|
|
self.ip_address = Current.ip_address
|
|
|
|
end
|
2025-05-15 10:19:56 -04:00
|
|
|
|
|
|
|
def get_preferred_tab(tab_key)
|
|
|
|
data.dig("tab_preferences", tab_key)
|
|
|
|
end
|
|
|
|
|
|
|
|
def set_preferred_tab(tab_key, tab_value)
|
|
|
|
data["tab_preferences"] ||= {}
|
|
|
|
data["tab_preferences"][tab_key] = tab_value
|
|
|
|
save!
|
|
|
|
end
|
2024-10-03 14:42:22 -04:00
|
|
|
end
|