This commit is contained in:
tonyrewin 2022-11-23 14:56:09 +03:00
parent c6128ac641
commit 80b87574e6

View File

@ -9,9 +9,9 @@ class JWTCodec:
@staticmethod
def encode(user: AuthInput, exp: datetime) -> str:
issued = int(datetime.now().timestamp())
print('[jwtcodec] issued at %r' % issued)
print('[auth.jwtcodec] issued at %r' % issued)
expires = int(exp.timestamp())
print('[jwtcodec] expires at %r' % expires)
print('[auth.jwtcodec] expires at %r' % expires)
payload = {
"user_id": user.id,
"username": user.email or user.phone,
@ -23,7 +23,7 @@ class JWTCodec:
try:
return jwt.encode(payload, JWT_SECRET_KEY, JWT_ALGORITHM)
except Exception as e:
print('[jwtcodec] JWT encode error %r' % e)
print('[auth.jwtcodec] JWT encode error %r' % e)
@staticmethod
def decode(token: str, verify_exp: bool = True) -> TokenPayload:
@ -39,7 +39,7 @@ class JWTCodec:
issuer="discours"
)
r = TokenPayload(**payload)
print('[jwtcodec] debug payload %r' % r)
print('[auth.jwtcodec] debug payload %r' % r)
return r
except jwt.InvalidIssuedAtError:
raise ExpiredToken('check token issued time')