equal
deleted
inserted
replaced
26 To view the current user information and a form for logging in and out, |
26 To view the current user information and a form for logging in and out, |
27 supply no parameters. |
27 supply no parameters. |
28 """ |
28 """ |
29 |
29 |
30 |
30 |
|
31 import cgi |
31 import Cookie |
32 import Cookie |
32 import cgi |
33 import md5 |
33 import os |
34 import os |
34 import sys |
35 import sys |
35 import urllib |
36 import urllib |
36 |
37 |
37 |
38 |
64 |
65 |
65 cookie_value = '' |
66 cookie_value = '' |
66 if cookie_name in cookie: |
67 if cookie_name in cookie: |
67 cookie_value = cookie[cookie_name].value |
68 cookie_value = cookie[cookie_name].value |
68 |
69 |
69 email, admin = (cookie_value.split(':') + ['', ''])[:2] |
70 email, admin, user_id = (cookie_value.split(':') + ['', '', ''])[:3] |
70 return email, (admin == 'True') |
71 return email, (admin == 'True'), user_id |
71 |
72 |
72 |
73 |
73 def CreateCookieData(email, admin): |
74 def CreateCookieData(email, admin): |
74 """Creates cookie payload data. |
75 """Creates cookie payload data. |
75 |
76 |
80 String containing the cookie payload. |
81 String containing the cookie payload. |
81 """ |
82 """ |
82 admin_string = 'False' |
83 admin_string = 'False' |
83 if admin: |
84 if admin: |
84 admin_string = 'True' |
85 admin_string = 'True' |
85 return '%s:%s' % (email, admin_string) |
86 if email: |
|
87 user_id_digest = md5.new(email.lower()).digest() |
|
88 user_id = '1' + ''.join(['%02d' % ord(x) for x in user_id_digest])[:20] |
|
89 else: |
|
90 user_id = '' |
|
91 return '%s:%s:%s' % (email, admin_string, user_id) |
86 |
92 |
87 |
93 |
88 def SetUserInfoCookie(email, admin, cookie_name=COOKIE_NAME): |
94 def SetUserInfoCookie(email, admin, cookie_name=COOKIE_NAME): |
89 """Creates a cookie to set the user information for the requestor. |
95 """Creates a cookie to set the user information for the requestor. |
90 |
96 |