'Remove the current authenticated user in the request which is invalid
but only if the user is authenticated via the RemoteUserBackend.'

def _remove_invalid_user(self, request):

    try:
        stored_backend = load_backend(request.session.get(auth.BACKEND_SESSION_KEY, ''))
    except ImportError:
        auth.logout(request)
    else:
        if isinstance(stored_backend, RemoteUserBackend):
            auth.logout(request)
