helpers.py 文件源码

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

项目:wger-lycan-clan 作者: andela 项目源码 文件源码
def check_token(uidb64, token):
    '''
    Checks that the user token is correct.

    :param uidb:
    :param token:
    :return: True on success, False in all other situations
    '''
    if uidb64 is not None and token is not None:
        try:
            uid = int(urlsafe_base64_decode(uidb64))
        except ValueError as e:
            logger.info("Could not decode UID: {0}".format(e))
            return False
        user = User.objects.get(pk=uid)

        if user is not None and default_token_generator.check_token(user, token):
            return True

    return False
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号