|
@@ -28,14 +28,20 @@ class UidTokenObject:
|
|
|
token = self.token
|
|
|
if self.token is None:
|
|
|
return False
|
|
|
- res = jwt.decode(token, UID_TOKEN_KEY, algorithms='HS256')
|
|
|
- print(res)
|
|
|
- UID = res.get('uid', None)
|
|
|
- channel = res.get('channel', None)
|
|
|
- if UID is None:
|
|
|
- return False
|
|
|
- self.UID = UID
|
|
|
- self.channel = channel
|
|
|
+ try:
|
|
|
+ res = jwt.decode(token, UID_TOKEN_KEY, algorithms='HS256')
|
|
|
+ print(res)
|
|
|
+ UID = res.get('uid', None)
|
|
|
+ channel = res.get('channel', None)
|
|
|
+ if UID is None:
|
|
|
+ return False
|
|
|
+ self.UID = UID
|
|
|
+ self.channel = channel
|
|
|
+ except jwt.ExpiredSignatureError as e:
|
|
|
+ print('过期')
|
|
|
+ print(repr(e))
|
|
|
+ except Exception as e:
|
|
|
+ print(repr(e))
|
|
|
|
|
|
def generate(self, data={}):
|
|
|
token = jwt.encode(data, UID_TOKEN_KEY, algorithm='HS256').decode('utf-8')
|