macropin / django-registration

Django-registration (redux) provides user registration functionality for Django websites.
http://django-registration-redux.readthedocs.org
Other
974 stars 348 forks source link

ACCOUNT_ACTIVATION_DAYS not an int #386

Closed AntonOfTheWoods closed 4 years ago

AntonOfTheWoods commented 4 years ago

I am getting ACCOUNT_ACTIVATION_DAYS from an envvar via getenv and forgot to cast as an int before assignment. That left me with a very cryptic error message - '>' not supported between instances of 'float' and 'str' - in django/core/signing.py. signing.loads requires an int (or at least a number) and * int in python on a string will repeat that string int times rather than complain... Leading to the error. The relevant code in django-registration is:

            username = signing.loads(
                activation_key,
                salt=REGISTRATION_SALT,
                max_age=settings.ACCOUNT_ACTIVATION_DAYS * 86400,
            )

Simply wrapping an int around settings.ACCOUNT_ACTIVATION_DAYS would make for a super-easy "fix", in the sense that it's documented and int is pretty sensible (IMHO). Would you be interested in a PR? What would that PR need to look like? (I won't have time for lots of tests for a few weeks).

AntonOfTheWoods commented 4 years ago

Man it's annoying that this repo is the one that always comes up in Google...