Mercurial > public > sg101
comparison wiki/middleware.py @ 841:47521d9e94bd
Fix unicode bug when setting wiki cookie.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 04 Oct 2014 17:34:51 -0500 |
parents | efac466a05d4 |
children | ba3230aba90c |
comparison
equal
deleted
inserted
replaced
840:7735f8a6bd1f | 841:47521d9e94bd |
---|---|
23 | 23 |
24 # The key part of the cookie is just a string that would make things | 24 # The key part of the cookie is just a string that would make things |
25 # difficult for a spoofer; something that can't be easily made up: | 25 # difficult for a spoofer; something that can't be easily made up: |
26 | 26 |
27 h = hashlib.sha256() | 27 h = hashlib.sha256() |
28 h.update(user.username + user.email) | 28 h.update(user.username.encode('utf-8')) |
29 h.update(user.email.encode('utf-8')) | |
29 h.update(now.isoformat()) | 30 h.update(now.isoformat()) |
30 h.update(''.join(random.sample(string.printable, 64))) | 31 h.update(''.join(random.sample(string.printable, 64))) |
31 h.update(settings.SECRET_KEY) | 32 h.update(settings.SECRET_KEY) |
32 key = h.hexdigest() | 33 key = h.hexdigest() |
33 | 34 |