Description:
shows warning message when user cannot log in in single user mode
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r301:bdf9a550f783 - - 1 file changed: 1 inserted, 0 deleted

@@ -12,48 +12,49
12 12 end
13 13
14 14 def authorization_by_roles(allowed_roles)
15 15 return false unless authenticate
16 16 user = User.find(session[:user_id])
17 17 unless user.roles.detect { |role| allowed_roles.member?(role.name) }
18 18 flash[:notice] = 'You are not authorized to view the page you requested'
19 19 redirect_to :controller => 'main', :action => 'login'
20 20 return false
21 21 end
22 22 end
23 23
24 24 protected
25 25
26 26 def authenticate
27 27 unless session[:user_id]
28 28 redirect_to :controller => 'main', :action => 'login'
29 29 return false
30 30 end
31 31
32 32 # check if run in single user mode
33 33 if Configuration[SINGLE_USER_MODE_CONF_KEY]
34 34 user = User.find(session[:user_id])
35 35 if user==nil or (not user.admin?)
36 + flash[:notice] = 'You cannot log in at this time'
36 37 redirect_to :controller => 'main', :action => 'login'
37 38 return false
38 39 end
39 40 return true
40 41 end
41 42
42 43 if Configuration.multicontests?
43 44 user = User.find(session[:user_id])
44 45 return true if user.admin?
45 46 begin
46 47 if user.contest_stat(true).forced_logout
47 48 flash[:notice] = 'You have been automatically logged out.'
48 49 redirect_to :controller => 'main', :action => 'index'
49 50 end
50 51 rescue
51 52 end
52 53 end
53 54 return true
54 55 end
55 56
56 57 def authorization
57 58 return false unless authenticate
58 59 user = User.find(session[:user_id])
59 60 unless user.roles.detect { |role|
You need to be logged in to leave comments. Login now