Description:
fixed login error message recurring problem
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r229:c28a214e4637 - - 1 file changed: 1 inserted, 1 deleted

@@ -1,72 +1,72
1 class MainController < ApplicationController
1 class MainController < ApplicationController
2
2
3 before_filter :authenticate, :except => [:index, :login]
3 before_filter :authenticate, :except => [:index, :login]
4 before_filter :check_viewability, :except => [:index, :login]
4 before_filter :check_viewability, :except => [:index, :login]
5
5
6 # COMMENTED OUT: filter in each action instead
6 # COMMENTED OUT: filter in each action instead
7 # before_filter :verify_time_limit, :only => [:submit]
7 # before_filter :verify_time_limit, :only => [:submit]
8
8
9 verify :method => :post, :only => [:submit],
9 verify :method => :post, :only => [:submit],
10 :redirect_to => { :action => :index }
10 :redirect_to => { :action => :index }
11
11
12 # COMMENT OUT: only need when having high load
12 # COMMENT OUT: only need when having high load
13 # caches_action :index, :login
13 # caches_action :index, :login
14
14
15 # NOTE: This method is not actually needed, 'config/routes.rb' has
15 # NOTE: This method is not actually needed, 'config/routes.rb' has
16 # assigned action login as a default action.
16 # assigned action login as a default action.
17 def index
17 def index
18 redirect_to :action => 'login'
18 redirect_to :action => 'login'
19 end
19 end
20
20
21 def login
21 def login
22 saved_notice = flash[:notice]
22 saved_notice = flash[:notice]
23 reset_session
23 reset_session
24 - flash[:notice] = saved_notice
24 + flash.now[:notice] = saved_notice
25
25
26 # EXPERIMENT:
26 # EXPERIMENT:
27 # Hide login if in single user mode and the url does not
27 # Hide login if in single user mode and the url does not
28 # explicitly specify /login
28 # explicitly specify /login
29 #
29 #
30 # logger.info "PATH: #{request.path}"
30 # logger.info "PATH: #{request.path}"
31 # if Configuration['system.single_user_mode'] and
31 # if Configuration['system.single_user_mode'] and
32 # request.path!='/main/login'
32 # request.path!='/main/login'
33 # @hidelogin = true
33 # @hidelogin = true
34 # end
34 # end
35
35
36 @announcements = Announcement.find_for_frontpage
36 @announcements = Announcement.find_for_frontpage
37 render :action => 'login', :layout => 'empty'
37 render :action => 'login', :layout => 'empty'
38 end
38 end
39
39
40 def list
40 def list
41 prepare_list_information
41 prepare_list_information
42 end
42 end
43
43
44 def help
44 def help
45 @user = User.find(session[:user_id])
45 @user = User.find(session[:user_id])
46 end
46 end
47
47
48 def submit
48 def submit
49 user = User.find(session[:user_id])
49 user = User.find(session[:user_id])
50
50
51 @submission = Submission.new(params[:submission])
51 @submission = Submission.new(params[:submission])
52 @submission.user = user
52 @submission.user = user
53 @submission.language_id = 0
53 @submission.language_id = 0
54 if (params['file']) and (params['file']!='')
54 if (params['file']) and (params['file']!='')
55 @submission.source = params['file'].read
55 @submission.source = params['file'].read
56 @submission.source_filename = params['file'].original_filename
56 @submission.source_filename = params['file'].original_filename
57 end
57 end
58 @submission.submitted_at = Time.new.gmtime
58 @submission.submitted_at = Time.new.gmtime
59
59
60 if Configuration.time_limit_mode? and user.contest_finished?
60 if Configuration.time_limit_mode? and user.contest_finished?
61 @submission.errors.add_to_base "The contest is over."
61 @submission.errors.add_to_base "The contest is over."
62 prepare_list_information
62 prepare_list_information
63 render :action => 'list' and return
63 render :action => 'list' and return
64 end
64 end
65
65
66 if @submission.valid?
66 if @submission.valid?
67 if @submission.save == false
67 if @submission.save == false
68 flash[:notice] = 'Error saving your submission'
68 flash[:notice] = 'Error saving your submission'
69 elsif Task.create(:submission_id => @submission.id,
69 elsif Task.create(:submission_id => @submission.id,
70 :status => Task::STATUS_INQUEUE) == false
70 :status => Task::STATUS_INQUEUE) == false
71 flash[:notice] = 'Error adding your submission to task queue'
71 flash[:notice] = 'Error adding your submission to task queue'
72 end
72 end
You need to be logged in to leave comments. Login now