def validate_key(self, activation_key):
try:
username = signing.loads(
activation_key,
salt=settings.REGISTRATION_SALT,
max_age=settings.ACCOUNT_ACTIVATION_DAYS * 86400
)
return username
# SignatureExpired is a subclass of BadSignature, so this will
# catch either one.
except signing.SignatureExpired:
self.template_name = "accounts/activation_error.html"
self.error_reason = "Your code has expired"
return None
except signing.BadSignature:
self.template_name = "accounts/activation_error.html"
self.error_reason = "Bad activation key"
return None
评论列表
文章目录