mirror of
https://github.com/django/django.git
synced 2025-10-27 07:36:08 +00:00
Fixed #7919 -- md5 and sha modules are deprecated since Python 2.5, use hashlib module when available. Patch from Karen Tracey.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8193 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -50,17 +50,17 @@ class PasswordResetTokenGenerator(object):
|
||||
# last_login will also change), we produce a hash that will be
|
||||
# invalid as soon as it is used.
|
||||
# We limit the hash to 20 chars to keep URL short
|
||||
import sha
|
||||
hash = sha.new(settings.SECRET_KEY + unicode(user.id) +
|
||||
user.password + unicode(user.last_login) +
|
||||
unicode(timestamp)).hexdigest()[::2]
|
||||
from django.utils.hashcompat import sha_constructor
|
||||
hash = sha_constructor(settings.SECRET_KEY + unicode(user.id) +
|
||||
user.password + unicode(user.last_login) +
|
||||
unicode(timestamp)).hexdigest()[::2]
|
||||
return "%s-%s" % (ts_b36, hash)
|
||||
|
||||
def _num_days(self, dt):
|
||||
return (dt - date(2001,1,1)).days
|
||||
return (dt - date(2001,1,1)).days
|
||||
|
||||
def _today(self):
|
||||
# Used for mocking in tests
|
||||
return date.today()
|
||||
return date.today()
|
||||
|
||||
default_token_generator = PasswordResetTokenGenerator()
|
||||
|
||||
Reference in New Issue
Block a user