ubernostrum / django-registration

An extensible user-registration app for Django.
BSD 3-Clause "New" or "Revised" License
923 stars 241 forks source link

ACCOUNT_ACTIVATION_DAYS not an int #216

Closed AntonOfTheWoods closed 3 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).

ubernostrum commented 3 years ago

I don't think this is something that can really be fixed -- plenty of Django settings require specific non-string types, and at some point it just has to be up to the developer to work out the error when one of them is supplied as the wrong type.