def _remove_invalid_user(self, request):
        try:
            stored_backend = load_backend(request.session.get(auth.BACKEND_SESSION_KEY, ''))
        except ImportError:
            # backend failed to load
            auth.logout(request)
        else:
            if isinstance(stored_backend, RemoteUserBackend):
                auth.logout(request)
Removes the current authenticated user in the request which is invalid
dataset/ETHPy150Open django/django/django/contrib/auth/middleware.py/RemoteUserMiddleware._remove_invalid_user