ExpiringTokenGenerator

ExpiringTokenGenerator implements single-use authentication tokens that expire after a configurable amount of time (24 hours by default). It is designed to be used in scenarios such as password reset links or email confirmation links, but could be used in other scenarios as well.

Django token generators for single-use authentications.

class smarter.lib.django.token_generators.ExpiringTokenGenerator(expiration=86400)[source]

Bases: PasswordResetTokenGenerator

An object of this class can generate a token that expires after a certain amount of time.

__init__(expiration=86400)[source]
adjusted_timestamp(timestamp)[source]
Return type:

int

Extract the user from the uid and token and validate.

Return type:

User

Create an encoded url link that expires after a certain amount of time.

Return type:

str

static get_timestamp()[source]
Return type:

int

uidb64_to_user(uidb64)[source]
Return type:

User

user_to_uidb64(user)[source]
Return type:

str

validate(user, token)[source]

Check that a password reset token is correct for a given user.

Return type:

bool

exception smarter.lib.django.token_generators.SmarterTokenConversionError(message='')[source]

Bases: SmarterTokenError

exception smarter.lib.django.token_generators.SmarterTokenError(message='')[source]

Bases: SmarterException

Base class for all token-related exceptions.

exception smarter.lib.django.token_generators.SmarterTokenExpiredError(message='')[source]

Bases: SmarterTokenError

exception smarter.lib.django.token_generators.SmarterTokenIntegrityError(message='')[source]

Bases: SmarterTokenError

exception smarter.lib.django.token_generators.SmarterTokenParseError(message='')[source]

Bases: SmarterTokenError