diff options
author | ThibG <thib@sitedethib.com> | 2018-05-11 13:20:58 +0200 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2018-05-11 13:20:58 +0200 |
commit | 352bae8c3ef2aca41de4aacb85d5e036a1d2bace (patch) | |
tree | a597388c0e336da6ddd63978516e490ff0b0349f /app/controllers/concerns | |
parent | b241cb2704b1f7f2006473895183d51a3a1636a8 (diff) |
Update session activation time (fixes #5605) (#7408)
Diffstat (limited to 'app/controllers/concerns')
-rw-r--r-- | app/controllers/concerns/session_tracking_concern.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/app/controllers/concerns/session_tracking_concern.rb b/app/controllers/concerns/session_tracking_concern.rb new file mode 100644 index 000000000..45361b019 --- /dev/null +++ b/app/controllers/concerns/session_tracking_concern.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +module SessionTrackingConcern + extend ActiveSupport::Concern + + UPDATE_SIGN_IN_HOURS = 24 + + 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 < UPDATE_SIGN_IN_HOURS.hours.ago + end +end |