Description:
update heartbeat add try-to-login-from-other-ip loggin (by printing to stdout)
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r539:c49187a88c77 - - 2 files changed: 2 inserted, 1 deleted

@@ -66,12 +66,13
66 66 #this assume that we have already authenticate normally
67 67 unless GraderConfiguration[MULTIPLE_IP_LOGIN_CONF_KEY]
68 68 user = User.find(session[:user_id])
69 69 if (not user.admin? and user.last_ip and user.last_ip != request.remote_ip)
70 70 flash[:notice] = "You cannot use the system from #{request.remote_ip}. Your last ip is #{user.last_ip}"
71 71 redirect_to :controller => 'main', :action => 'login'
72 + puts "CHEAT: user #{user.login} tried to login from '#{request.remote_ip}' while last ip is '#{user.last_ip}' at #{Time.zone.now}"
72 73 return false
73 74 end
74 75 unless user.last_ip
75 76 user.last_ip = request.remote_ip
76 77 user.save
77 78 end
@@ -23,9 +23,9
23 23
24 24 render text: (GraderConfiguration['right.heartbeat_response'] || 'OK')
25 25 end
26 26
27 27 def index
28 28 @hb = HeartBeat.where("updated_at >= ?",Time.zone.now-2.hours).includes(:user).order(:user_id).all
29 - @num = HeartBeat.where("updated_at >= ?",Time.zone.now-5.minutes).count
29 + @num = HeartBeat.where("updated_at >= ?",Time.zone.now-5.minutes).count(:user_id,distinct: true)
30 30 end
31 31 end
You need to be logged in to leave comments. Login now