def process_request(self, request): # Set the header if token is present or a session exists if request.META.get(RemoteUserMiddleware.header, None): return token = request.COOKIES.get(jwt_settings.TOKEN_COOKIE_NAME, None) if token is not None: token_obj = JWTToken(token) if token_obj.is_valid(): request.META[RemoteUserMiddleware.header] = token_obj.payload
def decode_token(token): token_obj = JWTToken(token) if token_obj.is_valid(): return token_obj.payload return None