Ticket #10265: token.patch
File token.patch, 1.3 KB (added by , 16 years ago) |
---|
-
contrib/auth/tokens.py
52 52 # We limit the hash to 20 chars to keep URL short 53 53 from django.utils.hashcompat import sha_constructor 54 54 hash = sha_constructor(settings.SECRET_KEY + unicode(user.id) + 55 user.password + u nicode(user.last_login) +55 user.password + user.last_login.strftime('%Y-%m-%d %H:%M:%S') + 56 56 unicode(timestamp)).hexdigest()[::2] 57 57 return "%s-%s" % (ts_b36, hash) 58 58 -
contrib/auth/tests/tokens.py
8 8 >>> p0.check_token(u, tk1) 9 9 True 10 10 11 >>> u = User.objects.create_user('comebackkid', 'test3@example.com', 'testpw') 12 >>> p0 = PasswordResetTokenGenerator() 13 >>> tk1 = p0.make_token(u) 14 >>> reload = User.objects.get(username='comebackkid') 15 >>> tk2 = p0.make_token(reload) 16 >>> tk1 == tk2 17 True 18 11 19 Tests to ensure we can use the token after n days, but no greater. 12 20 Use a mocked version of PasswordResetTokenGenerator so we can change 13 21 the value of 'today'