def get_identifier(self):
""" Gets the instance, if token is valid.
:param klass: the class (must be model.Model instance)
May throw DoesNotExist
:returns: instance if signature is ok, None else.
"""
try:
payload = signing.Signer().unsign(self.token)
except signing.BadSignature:
return None
else:
d = json.loads(force_text(urlsafe_base64_decode(payload)))
return d.get('identifier')
评论列表
文章目录