Merge branch 'prepare-comments' of github.com:Discours/discours-backend into prepare-comments
This commit is contained in:
commit
782c34a62b
|
@ -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')
|
||||||
|
|
|
@ -36,7 +36,7 @@ class ReactedStorage:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
async def get_shout_stat(slug):
|
async def get_shout_stat(slug):
|
||||||
viewed = int(await ViewedStorage.get_shout(slug))
|
viewed = int(await ViewedStorage.get_shout(slug))
|
||||||
print(viewed)
|
# print(viewed)
|
||||||
return {
|
return {
|
||||||
"viewed": viewed,
|
"viewed": viewed,
|
||||||
"reacted": len(await ReactedStorage.get_shout(slug)),
|
"reacted": len(await ReactedStorage.get_shout(slug)),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user