minimal requirements, one schema, readme update

This commit is contained in:
2021-06-30 14:46:19 +03:00
parent 4f2f4187fe
commit 378f4b61b1
18 changed files with 389 additions and 456 deletions

View File

@@ -2,7 +2,7 @@ from functools import wraps
from typing import Optional, Tuple
from graphql import GraphQLResolveInfo
from jwt import DecodeError, ExpiredSignatureError
import jwt
from starlette.authentication import AuthenticationBackend
from starlette.requests import HTTPConnection
@@ -29,14 +29,14 @@ class _Authenticate:
"""
try:
payload = Token.decode(token)
except ExpiredSignatureError:
except exceptions.ExpiredSignatureError:
payload = Token.decode(token, verify_exp=False)
if not await cls.exists(payload.user_id, token):
raise InvalidToken("Login expired, please login again")
if payload.device == "mobile": # noqa
"we cat set mobile token to be valid forever"
return payload
except DecodeError as e:
except exceptions.JWTDecodeError as e:
raise InvalidToken("token format error") from e
else:
if not await cls.exists(payload.user_id, token):