X-Git-Url: http://git.ithinksw.org/philo.git/blobdiff_plain/943e8bc4af0c11b0ace3811199e3b0844c4c3fbc..1a56dac4a9131e6c453ef496fe8a496969e8ff0d:/philo/contrib/waldo/tokens.py?ds=inline diff --git a/philo/contrib/waldo/tokens.py b/philo/contrib/waldo/tokens.py index 858b073..1a7c3a9 100644 --- a/philo/contrib/waldo/tokens.py +++ b/philo/contrib/waldo/tokens.py @@ -1,5 +1,12 @@ """ -Based on django.contrib.auth.tokens +Based on :mod:`django.contrib.auth.tokens`. Supports the following settings: + +:setting:`WALDO_REGISTRATION_TIMEOUT_DAYS` + The number of days a registration link will be valid before expiring. Default: 1. + +:setting:`WALDO_EMAIL_TIMEOUT_DAYS` + The number of days an email change link will be valid before expiring. Default: 1. + """ from hashlib import sha1 @@ -15,13 +22,10 @@ EMAIL_TIMEOUT_DAYS = getattr(settings, 'WALDO_EMAIL_TIMEOUT_DAYS', 1) class RegistrationTokenGenerator(PasswordResetTokenGenerator): - """ - Strategy object used to generate and check tokens for the user registration mechanism. - """ + """Strategy object used to generate and check tokens for the user registration mechanism.""" + def check_token(self, user, token): - """ - Check that a registration token is correct for a given user. - """ + """Check that a registration token is correct for a given user.""" # If the user is active, the hash can't be valid. if user.is_active: return False @@ -61,13 +65,10 @@ registration_token_generator = RegistrationTokenGenerator() class EmailTokenGenerator(PasswordResetTokenGenerator): - """ - Strategy object used to generate and check tokens for a user email change mechanism. - """ + """Strategy object used to generate and check tokens for a user email change mechanism.""" + def make_token(self, user, email): - """ - Returns a token that can be used once to do an email change for the given user and email. - """ + """Returns a token that can be used once to do an email change for the given user and email.""" return self._make_token_with_timestamp(user, email, self._num_days(self._today())) def check_token(self, user, email, token):