This commit is contained in:
bniwredyc 2023-07-13 16:48:21 +02:00
parent fee472b451
commit 2b6496b34d

View File

@ -21,12 +21,12 @@ class JWTAuthenticate(AuthenticationBackend):
) -> Optional[Tuple[AuthCredentials, AuthUser]]: ) -> Optional[Tuple[AuthCredentials, AuthUser]]:
if SESSION_TOKEN_HEADER not in request.headers: if SESSION_TOKEN_HEADER not in request.headers:
return AuthCredentials(scopes=[]), AuthUser(user_id=None) return AuthCredentials(scopes={}), AuthUser(user_id=None)
token = request.headers.get(SESSION_TOKEN_HEADER) token = request.headers.get(SESSION_TOKEN_HEADER)
if not token: if not token:
print("[auth.authenticate] no token in header %s" % SESSION_TOKEN_HEADER) print("[auth.authenticate] no token in header %s" % SESSION_TOKEN_HEADER)
return AuthCredentials(scopes=[], error_message=str("no token")), AuthUser( return AuthCredentials(scopes={}, error_message=str("no token")), AuthUser(
user_id=None user_id=None
) )
@ -57,7 +57,7 @@ class JWTAuthenticate(AuthenticationBackend):
except exc.NoResultFound: except exc.NoResultFound:
pass pass
return AuthCredentials(scopes=[], error_message=str('Invalid token')), AuthUser(user_id=None) return AuthCredentials(scopes={}, error_message=str('Invalid token')), AuthUser(user_id=None)
def login_required(func): def login_required(func):