utils.py 文件源码

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

项目:django-rest-framework-passwordless 作者: aaronn 项目源码 文件源码
def validate_token_age(callback_token):
    """
    Returns True if a given token is within the age expiration limit.
    """
    try:
        token = CallbackToken.objects.get(key=callback_token, is_active=True)
        seconds = (timezone.now() - token.created_at).total_seconds()
        token_expiry_time = api_settings.PASSWORDLESS_TOKEN_EXPIRE_TIME

        if seconds <= token_expiry_time:
            return True
        else:
            # Invalidate our token.
            token.is_active = False
            token.save()
            return False

    except CallbackToken.DoesNotExist:
        # No valid token.
        return False
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号