Logic for supporting JWT tokens both as bytes and strings [closes #197]

This commit is contained in:
Fabio Manganiello 2021-08-24 22:55:42 +02:00
parent a8064d2add
commit 87b70716c1

View file

@ -191,7 +191,10 @@ class UserManager:
'expires_at': expires_at.timestamp() if expires_at else None,
}
return jwt.encode(payload, priv_key, algorithm='RS256').decode()
token = jwt.encode(payload, priv_key, algorithm='RS256')
if isinstance(token, bytes):
token = token.decode()
return token
@staticmethod
def validate_jwt_token(token: str) -> Dict[str, str]: