Description:
fix user.admin? bug
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r757:35d86dd3635c - - 2 files changed: 5 inserted, 4 deleted
@@ -68,7 +68,7 | |||||
|
68 |
|
68 | ||
|
69 | # check if run in single user mode |
|
69 | # check if run in single user mode |
|
70 | if GraderConfiguration[SINGLE_USER_MODE_CONF_KEY] |
|
70 | if GraderConfiguration[SINGLE_USER_MODE_CONF_KEY] |
|
71 |
- if @current_user==nil || ( |
|
71 | + if @current_user==nil || (!@current_user.admin?) |
|
72 | unauthorized_redirect('You cannot log in at this time') |
|
72 | unauthorized_redirect('You cannot log in at this time') |
|
73 | return false |
|
73 | return false |
|
74 | end |
|
74 | end |
@@ -108,10 +108,11 | |||||
|
108 | #this assume that we have already authenticate normally |
|
108 | #this assume that we have already authenticate normally |
|
109 | unless GraderConfiguration[MULTIPLE_IP_LOGIN_CONF_KEY] |
|
109 | unless GraderConfiguration[MULTIPLE_IP_LOGIN_CONF_KEY] |
|
110 | user = User.find(session[:user_id]) |
|
110 | user = User.find(session[:user_id]) |
|
111 | - if (not @current_user.admin? && user.last_ip && user.last_ip != request.remote_ip) |
|
111 | + puts "User admin #{user.admin?}" |
|
|
112 | + if (!user.admin? && user.last_ip && user.last_ip != request.remote_ip) | ||
|
112 | flash[:notice] = "You cannot use the system from #{request.remote_ip}. Your last ip is #{user.last_ip}" |
|
113 | flash[:notice] = "You cannot use the system from #{request.remote_ip}. Your last ip is #{user.last_ip}" |
|
|
114 | + puts "hahaha" | ||
|
113 | redirect_to :controller => 'main', :action => 'login' |
|
115 | redirect_to :controller => 'main', :action => 'login' |
|
114 | - puts "CHEAT: user #{user.login} tried to login from '#{request.remote_ip}' while last ip is '#{user.last_ip}' at #{Time.zone.now}" |
|
||
|
115 | return false |
|
116 | return false |
|
116 | end |
|
117 | end |
|
117 | unless user.last_ip |
|
118 | unless user.last_ip |
You need to be logged in to leave comments.
Login now