def authenticate(self, request, **kwargs):
"""
Validates a lost_key request by hash, id, and expiration time
"""
user_hash = request.QUERY_PARAMS.get('hash', None)
if not user_hash:
user_hash = request.DATA.get('hash')
lost_key_id = request.parser_context.get('view').kwargs.get('pk')
try:
lost_key = LostKey.objects.get(hash=user_hash,
pk=lost_key_id,
expires_at__gte=datetime.utcnow().
replace(tzinfo=utc),
used=False)
return lost_key.created_by, lost_key.hash
except:
return None
评论列表
文章目录