authentication.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:vaultier 作者: Movile 项目源码 文件源码
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
评论列表


问题


面经


文章

微信
公众号

扫码关注公众号