diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -69,6 +69,7 @@ if (not user.admin? and user.last_ip and user.last_ip != request.remote_ip) flash[:notice] = "You cannot use the system from #{request.remote_ip}. Your last ip is #{user.last_ip}" redirect_to :controller => 'main', :action => 'login' + puts "CHEAT: user #{user.login} tried to login from '#{request.remote_ip}' while last ip is '#{user.last_ip}' at #{Time.zone.now}" return false end unless user.last_ip diff --git a/app/controllers/heartbeat_controller.rb b/app/controllers/heartbeat_controller.rb --- a/app/controllers/heartbeat_controller.rb +++ b/app/controllers/heartbeat_controller.rb @@ -26,6 +26,6 @@ def index @hb = HeartBeat.where("updated_at >= ?",Time.zone.now-2.hours).includes(:user).order(:user_id).all - @num = HeartBeat.where("updated_at >= ?",Time.zone.now-5.minutes).count + @num = HeartBeat.where("updated_at >= ?",Time.zone.now-5.minutes).count(:user_id,distinct: true) end end