blob: 3f56c0d0267856cfc205bbde310c524d4289ec67 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# frozen_string_literal: true
module SessionTrackingConcern
extend ActiveSupport::Concern
SESSION_UPDATE_FREQUENCY = 24.hours.freeze
included do
before_action :set_session_activity
end
private
def set_session_activity
return unless session_needs_update?
current_session.touch
end
def session_needs_update?
!current_session.nil? && current_session.updated_at < SESSION_UPDATE_FREQUENCY.ago
end
end
|