Description:
prevent multiple place login using uuid cookie
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r883:327f656f4545 - - 1 file changed: 6 inserted, 3 deleted
@@ -71,6 +71,9 | |||
|
71 | 71 | unless cookies.encrypted[:uuid] |
|
72 | 72 | value = SecureRandom.uuid |
|
73 | 73 | cookies.encrypted[:uuid] = { value: value, expires: 20.year } |
|
74 | + return value | |
|
75 | + else | |
|
76 | + return cookies.encrypted[:uuid] | |
|
74 | 77 | end |
|
75 | 78 | end |
|
76 | 79 | |
@@ -131,13 +134,13 | |||
|
131 | 134 | #this assume that we have already authenticate normally |
|
132 | 135 | unless GraderConfiguration[MULTIPLE_IP_LOGIN_CONF_KEY] |
|
133 | 136 | user = User.find(session[:user_id]) |
|
134 |
- if (!user.admin? && user.last_ip && user.last_ip != |
|
|
135 |
- flash[:notice] = "You cannot use the system from |
|
|
137 | + if (!user.admin? && user.last_ip && user.last_ip != unique_visitor_id) | |
|
138 | + flash[:notice] = "You cannot use the system from two different places" | |
|
136 | 139 | redirect_to :controller => 'main', :action => 'login' |
|
137 | 140 | return false |
|
138 | 141 | end |
|
139 | 142 | unless user.last_ip |
|
140 |
- user.last_ip = |
|
|
143 | + user.last_ip = unique_visitor_id | |
|
141 | 144 | user.save |
|
142 | 145 | end |
|
143 | 146 | end |
You need to be logged in to leave comments.
Login now