about summary refs log tree commit diff
path: root/app/controllers/application_controller.rb
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-11-30 15:17:03 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-11-30 15:17:03 +0100
commitff21ff1489afd6a16d52acc05a71bd58abc401ac (patch)
tree2e515770d15242fbaab09ccbb8743065bc957c6e /app/controllers/application_controller.rb
parent872a35011a96f638d2e10564110f21e6f3bd0914 (diff)
Make User#current_sign_in_at actually track when user was last active,
by updating it at least every 24h if the user visits the site
Diffstat (limited to 'app/controllers/application_controller.rb')
-rw-r--r--app/controllers/application_controller.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index ba0098c71..bb52646a7 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -14,6 +14,7 @@ class ApplicationController < ActionController::Base
 
   before_action :store_current_location, except: :raise_not_found, unless: :devise_controller?
   before_action :set_locale
+  before_action :set_user_activity
 
   def raise_not_found
     raise ActionController::RoutingError, "No route matches #{params[:unmatched_route]}"
@@ -35,6 +36,10 @@ class ApplicationController < ActionController::Base
     redirect_to root_path unless current_user&.admin?
   end
 
+  def set_user_activity
+    current_user.touch(:current_sign_in_at) if !current_user.nil? && current_user.current_sign_in_at < 24.hours.ago
+  end
+
   protected
 
   def not_found