def METHOD_NAME(*args, **kwds) -> Tuple[HttpRequest, User] | None:
    result = f(*args, **kwds)
    if result is not None:
        request, user = result
        if not user.is_anonymous:
            login(request, user)
            AuthenticationMiddleware(placeholder_get_response).process_request(request)
        else:
            request.user = user
            request.auth = None
        env.request = request
        cache.clear()
    else:
        env.clear()
    return result