From 635f2969ba26b6e29dec037187b1bbecde9dcbfe Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Thu, 2 Feb 2023 11:58:29 +0000 Subject: [PATCH] Merge pull request #11621 from overleaf/jpa-targeted-access-check [web] cut down volume of user content domain access check requests GitOrigin-RevId: 42011325db9f421e8267c4d0215701dedae652f9 --- .../user-content-domain-access-check/index.ts | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/services/web/frontend/js/features/user-content-domain-access-check/index.ts b/services/web/frontend/js/features/user-content-domain-access-check/index.ts index c1de5b66f0..d6fa5dd10c 100644 --- a/services/web/frontend/js/features/user-content-domain-access-check/index.ts +++ b/services/web/frontend/js/features/user-content-domain-access-check/index.ts @@ -132,14 +132,22 @@ export async function checkUserContentDomainAccess() { const userId = `0${randomHex(12).slice(1)}` const buildId = genBuildId() const zone = pickZone() - const urls = [ - `${getMeta( - 'ol-compilesUserContentDomain' - )}/zone/${zone}/project/${projectId}/user/${userId}/build/${buildId}/output/output.pdf`, - `${getMeta( - 'ol-compilesUserContentDomain' - )}/zone/${zone}/project/${projectId}/build/${buildId}/output/output.pdf`, - ] + const urls = [] + if (getMeta('ol-user_id')) { + // Logged-in user + urls.push( + `${getMeta( + 'ol-compilesUserContentDomain' + )}/zone/${zone}/project/${projectId}/user/${userId}/build/${buildId}/output/output.pdf` + ) + } else { + // Anonymous user + urls.push( + `${getMeta( + 'ol-compilesUserContentDomain' + )}/zone/${zone}/project/${projectId}/build/${buildId}/output/output.pdf` + ) + } const cases = [] for (const url of urls) {