Description:
fixed login box showing in announcement box after user logged out in other tabs
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r249:11f906d2e75a - - 1 file changed: 10 inserted, 0 deleted

@@ -1,55 +1,59
1 1 class MainController < ApplicationController
2 2
3 3 before_filter :authenticate, :except => [:index, :login]
4 4 before_filter :check_viewability, :except => [:index, :login]
5 5
6 6 append_before_filter :update_user_start_time, :except => [:index, :login]
7 7
8 + # to prevent log in box to be shown when user logged out of the
9 + # system only in some tab
10 + prepend_before_filter :reject_announcement_refresh_when_logged_out, :only => [:announcements]
11 +
8 12 # COMMENTED OUT: filter in each action instead
9 13 # before_filter :verify_time_limit, :only => [:submit]
10 14
11 15 verify :method => :post, :only => [:submit],
12 16 :redirect_to => { :action => :index }
13 17
14 18 # COMMENT OUT: only need when having high load
15 19 # caches_action :index, :login
16 20
17 21 # NOTE: This method is not actually needed, 'config/routes.rb' has
18 22 # assigned action login as a default action.
19 23 def index
20 24 redirect_to :action => 'login'
21 25 end
22 26
23 27 def login
24 28 saved_notice = flash[:notice]
25 29 reset_session
26 30 flash.now[:notice] = saved_notice
27 31
28 32 # EXPERIMENT:
29 33 # Hide login if in single user mode and the url does not
30 34 # explicitly specify /login
31 35 #
32 36 # logger.info "PATH: #{request.path}"
33 37 # if Configuration['system.single_user_mode'] and
34 38 # request.path!='/main/login'
35 39 # @hidelogin = true
36 40 # end
37 41
38 42 @announcements = Announcement.find_for_frontpage
39 43 render :action => 'login', :layout => 'empty'
40 44 end
41 45
42 46 def list
43 47 prepare_list_information
44 48 end
45 49
46 50 def help
47 51 @user = User.find(session[:user_id])
48 52 end
49 53
50 54 def submit
51 55 user = User.find(session[:user_id])
52 56
53 57 @submission = Submission.new(params[:submission])
54 58 @submission.user = user
55 59 @submission.language_id = 0
@@ -281,50 +285,56
281 285 :output_size => output_size
282 286 }
283 287 end
284 288 end
285 289
286 290 # copied from grader/script/lib/test_request_helper.rb
287 291 def extract_running_stat(results)
288 292 running_stat_line = results[-1]
289 293
290 294 # extract exit status line
291 295 run_stat = ""
292 296 if !(/[Cc]orrect/.match(results[0]))
293 297 run_stat = results[0].chomp
294 298 else
295 299 run_stat = 'Program exited normally'
296 300 end
297 301
298 302 logger.info "Stat line: #{running_stat_line}"
299 303
300 304 # extract running time
301 305 if res = /r(.*)u(.*)s/.match(running_stat_line)
302 306 seconds = (res[1].to_f + res[2].to_f)
303 307 time_stat = "Time used: #{seconds} sec."
304 308 else
305 309 seconds = nil
306 310 time_stat = "Time used: n/a sec."
307 311 end
308 312
309 313 # extract memory usage
310 314 if res = /s(.*)m/.match(running_stat_line)
311 315 memory_used = res[1].to_i
312 316 else
313 317 memory_used = -1
314 318 end
315 319
316 320 return {
317 321 :msg => "#{run_stat}\n#{time_stat}",
318 322 :running_time => seconds,
319 323 :exit_status => run_stat,
320 324 :memory_usage => memory_used
321 325 }
322 326 end
323 327
324 328 def update_user_start_time
325 329 user = User.find(session[:user_id])
326 330 UserContestStat.update_user_start_time(user)
327 331 end
328 332
333 + def reject_announcement_refresh_when_logged_out
334 + if not session[:user_id]
335 + render :text => 'Access forbidden', :status => 403
336 + end
337 + end
338 +
329 339 end
330 340
You need to be logged in to leave comments. Login now