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