Skip to content

Commit

Permalink
set default time for accept_totp, fixes #5
Browse files Browse the repository at this point in the history
Thanks to jontrov@github for the patch and reporting the issue.
  • Loading branch information
bdauvergne committed Oct 4, 2012
1 parent 26df82e commit 6118997
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions oath/totp.py
Expand Up @@ -120,6 +120,8 @@ def accept_totp(key, response, format='dec6', period=30, t=None,
reliable source of time like an NTP server.
:rtype: a two element tuple
'''
if t is None:
t = int(time.time())
for i in range(max(-divmod(t, period)[0],-backward_drift),forward_drift+1):
d = (drift+i) * period
if totp(key, format=format, period=period, hash=hash, t=t+d) == str(response):
Expand Down

0 comments on commit 6118997

Please sign in to comment.