Description:
change to encrypted cookies
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r853:da84d756f1f9 - - 2 files changed: 8 inserted, 6 deleted
@@ -54,16 +54,18 | |||
|
54 | 54 | end |
|
55 | 55 | |
|
56 | 56 | unauthorized_redirect unless GraderConfiguration["right.view_testcase"] |
|
57 | 57 | end |
|
58 | 58 | |
|
59 | 59 | def unique_visitor_id |
|
60 | - unless cookies[:uuid] | |
|
60 | + unless cookies.encrypted[:uuid] | |
|
61 | 61 | value = SecureRandom.uuid |
|
62 | - cookies[:uuid] = { value: value, expires: 20.year } | |
|
62 | + cookies.encrypted[:uuid] = { value: value, expires: 20.year } | |
|
63 | 63 | end |
|
64 | + puts "encrypt " + cookies.encrypted[:uuid] | |
|
65 | + puts cookies[:uuid] | |
|
64 | 66 | end |
|
65 | 67 | |
|
66 | 68 | protected |
|
67 | 69 | |
|
68 | 70 | #redirect to root (and also force logout) |
|
69 | 71 | #if the user is not logged_in or the system is in "ADMIN ONLY" mode |
@@ -21,16 +21,16 | |||
|
21 | 21 | redirect_to :controller => 'main', :action => 'login' |
|
22 | 22 | return |
|
23 | 23 | end |
|
24 | 24 | |
|
25 | 25 | #store uuid when login |
|
26 | 26 | if user.last_ip.nil? |
|
27 | - user.last_ip = cookies[:uuid] | |
|
27 | + user.last_ip = cookies.encrypted[:uuid] | |
|
28 | 28 | else |
|
29 | - if user.last_ip != cookies[:uuid] | |
|
30 | - user.last_ip =cookies[:uuid] | |
|
29 | + if user.last_ip != cookies.encrypted[:uuid] | |
|
30 | + user.last_ip =cookies.encrypted[:uuid] | |
|
31 | 31 | #log different login |
|
32 | 32 | end |
|
33 | 33 | end |
|
34 | 34 | |
|
35 | 35 | #process logging in |
|
36 | 36 | session[:user_id] = user.id |
@@ -45,13 +45,13 | |||
|
45 | 45 | contest_stat.save |
|
46 | 46 | end |
|
47 | 47 | end |
|
48 | 48 | end |
|
49 | 49 | |
|
50 | 50 | #save login information |
|
51 | - Login.create(user_id: user.id, ip_address: cookies[:uuid]) | |
|
51 | + Login.create(user_id: user.id, ip_address: cookies.encrypted[:uuid]) | |
|
52 | 52 | |
|
53 | 53 | redirect_to :controller => 'main', :action => 'list' |
|
54 | 54 | end |
|
55 | 55 | |
|
56 | 56 | def site_login |
|
57 | 57 | begin |
You need to be logged in to leave comments.
Login now