Description:
add enabled option for user
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r670:f90ec3934e15 - - 1 file changed: 11 inserted, 13 deleted
@@ -39,13 +39,10 | |||||
|
39 |
|
39 | ||
|
40 | def testcase_authorization |
|
40 | def testcase_authorization |
|
41 | #admin always has privileged |
|
41 | #admin always has privileged |
|
42 | - puts "haha" |
|
||
|
43 | if @current_user.admin? |
|
42 | if @current_user.admin? |
|
44 | return true |
|
43 | return true |
|
45 | end |
|
44 | end |
|
46 |
|
45 | ||
|
47 | - puts "hehe" |
|
||
|
48 | - puts GraderConfiguration["right.view_testcase"] |
|
||
|
49 | unauthorized_redirect unless GraderConfiguration["right.view_testcase"] |
|
46 | unauthorized_redirect unless GraderConfiguration["right.view_testcase"] |
|
50 | end |
|
47 | end |
|
51 |
|
48 | ||
@@ -61,27 +58,28 | |||||
|
61 | return false |
|
58 | return false |
|
62 | end |
|
59 | end |
|
63 |
|
60 | ||
|
|
61 | + | ||
|
64 | # check if run in single user mode |
|
62 | # check if run in single user mode |
|
65 | if GraderConfiguration[SINGLE_USER_MODE_CONF_KEY] |
|
63 | if GraderConfiguration[SINGLE_USER_MODE_CONF_KEY] |
|
66 | - user = User.find_by_id(session[:user_id]) |
|
64 | + if @current_user==nil or (not @current_user.admin?) |
|
67 | - if user==nil or (not user.admin?) |
|
||
|
68 | flash[:notice] = 'You cannot log in at this time' |
|
65 | flash[:notice] = 'You cannot log in at this time' |
|
69 | redirect_to :controller => 'main', :action => 'login' |
|
66 | redirect_to :controller => 'main', :action => 'login' |
|
70 | return false |
|
67 | return false |
|
71 | end |
|
68 | end |
|
72 | - unless user.enabled? |
|
||
|
73 | - flash[:notice] = 'Your account is disabled' |
|
||
|
74 | - redirect_to :controller => 'main', :action => 'login' |
|
||
|
75 | - return false |
|
||
|
76 | - end |
|
||
|
77 | return true |
|
69 | return true |
|
78 | end |
|
70 | end |
|
79 |
|
71 | ||
|
|
72 | + # check if the user is enabled | ||
|
|
73 | + unless @current_user.enabled? or @current_user.admin? | ||
|
|
74 | + flash[:notice] = 'Your account is disabled' | ||
|
|
75 | + redirect_to :controller => 'main', :action => 'login' | ||
|
|
76 | + return false | ||
|
|
77 | + end | ||
|
|
78 | + | ||
|
80 | if GraderConfiguration.multicontests? |
|
79 | if GraderConfiguration.multicontests? |
|
81 | - user = User.find(session[:user_id]) |
|
80 | + return true if @current_user.admin? |
|
82 | - return true if user.admin? |
|
||
|
83 | begin |
|
81 | begin |
|
84 | - if user.contest_stat(true).forced_logout |
|
82 | + if @current_user.contest_stat(true).forced_logout |
|
85 | flash[:notice] = 'You have been automatically logged out.' |
|
83 | flash[:notice] = 'You have been automatically logged out.' |
|
86 | redirect_to :controller => 'main', :action => 'index' |
|
84 | redirect_to :controller => 'main', :action => 'index' |
|
87 | end |
|
85 | end |
You need to be logged in to leave comments.
Login now