Fix _generate_words method. The "nowish" variable tells us in which 5 minutes slot we are in. Therefore we increment the time slot by 1, not by 5 (minutes). [tbesluau]

svn path=/plone.formwidget.captcha/trunk/; revision=36895
This commit is contained in:
Timo Stollenwerk 2010-06-02 10:25:39 +00:00
parent 47b2d510c8
commit f2244736f5
2 changed files with 11 additions and 2 deletions

View File

@ -4,9 +4,14 @@ Changelog
1.0b1 - 2010-06-02
------------------
* Fix _generate_words method. The "nowish" variable tells us in which 5 minutes
slot we are in. Therefore we increment the time slot by 1, not by 5 (minutes).
[tbesluau]
* Declare that plone.formwidget.captcha provides a Captcha field that can be
used by plone.app.discussion to add a Captcha field to comment forms.
[timo]
[timo]
1.0a2 - 2010-01-28
------------------

View File

@ -74,9 +74,13 @@ class Captcha(BrowserView):
"""
session = self.request[COOKIE_ID]
nowish = _TEST_TIME or int(time.time() / 300)
# The line above defines nowish, which tells us what five minutes slot
# we're in. Indeed, every second, int(time.time()) increments by 1, so
# int(time.time() / 300) will increment by 1 every 5 minutes.
secret = getUtility(IKeyManager).secret()
seeds = [sha.new(secret + session + str(nowish)).digest(),
sha.new(secret + session + str(nowish - 5)).digest()]
sha.new(secret + session + str(nowish - 1)).digest()]
# The line above generates a seed based on the "nowish" of 5 minutes ago.
words = []
for seed in seeds: