mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-04-27 03:00:12 -04:00
cookies: Make over18 cookie not IP-hashed.
The over18 cookie's IP hashing behavior is of dubious use and is not at all compatible with efficient CDN caching.
This commit is contained in:
@@ -143,10 +143,7 @@ class PostController(ApiController):
|
||||
c.user.pref_over_18 = True
|
||||
c.user._commit()
|
||||
else:
|
||||
ip_hash = hashlib.sha1(request.ip).hexdigest()
|
||||
domain = g.domain if not c.frameless_cname else None
|
||||
c.cookies.add('over18', ip_hash,
|
||||
domain = domain)
|
||||
c.cookies.add("over18", "1")
|
||||
return self.redirect(dest)
|
||||
else:
|
||||
return self.redirect('/')
|
||||
|
||||
@@ -319,8 +319,10 @@ def over18():
|
||||
else:
|
||||
if 'over18' in c.cookies:
|
||||
cookie = c.cookies['over18'].value
|
||||
if cookie == sha1(request.ip).hexdigest():
|
||||
if cookie == "1":
|
||||
return True
|
||||
else:
|
||||
c.cookies["over18"] = Cookie(value="", expires=DELETE)
|
||||
|
||||
def set_obey_over18():
|
||||
"querystring parameter for API to obey over18 filtering rules"
|
||||
|
||||
Reference in New Issue
Block a user