server.py 文件源码

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

项目:litecord-reference 作者: lnmds 项目源码 文件源码
def token_find(self, token: str) -> int:
        """Return a user ID from a token.

        Parses the token to get the user ID and then unsigns it
        using the user's hashed password as a secret key
        """
        userid_encoded = token.split('.')[0]

        try:
            userid = int(base64.urlsafe_b64decode(userid_encoded))
        except (binascii.Error, ValueError):
            return None

        raw_user = self.get_raw_user(userid)
        if raw_user is None:
            return

        s = TimestampSigner(raw_user['password']['hash'])
        try:
            s.unsign(token)
        except itsdangerous.BadSignature:
            return

        return userid
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号