diff --git a/auth/authenticate.py b/auth/authenticate.py index 18bf11c3..255b4a5c 100644 --- a/auth/authenticate.py +++ b/auth/authenticate.py @@ -29,8 +29,7 @@ class JWTAuthenticate(AuthenticationBackend): user_id=None, username="" ) - if token.startswith("Bearer"): - token = token[len("Bearer "):] + token = token.split(" ")[-1] if len(token.split(".")) > 1: payload = await SessionToken.verify(token) diff --git a/resolvers/auth.py b/resolvers/auth.py index 6e2c894b..2cb7058b 100644 --- a/resolvers/auth.py +++ b/resolvers/auth.py @@ -33,8 +33,7 @@ async def get_current_user(_, info): auth: AuthCredentials = info.context["request"].auth token = info.context["request"].headers.get(SESSION_TOKEN_HEADER) - if token.startswith("Bearer"): - token = token[len("Bearer "):] + token = token.split(" ")[-1] with local_session() as session: user = session.query(User).where(User.id == auth.user_id).one()