# HG changeset patch # User Nattee Niparnan # Date 2015-09-16 06:29:27 # Node ID 81fa04a2af1980c4c0f9f6434842223bd6574186 # Parent 43102e2224507b4aaec251cc635ead1f7583f18f update heartbeat add try-to-login-from-other-ip loggin (by printing to stdout) (grafted from 0e4c832eeb6325f9747d2def63c511423a3b70d4) 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