From 47cb9b5a18b9a605b2cdd1c13ad5bbca7ddf401a Mon Sep 17 00:00:00 2001 From: Ike Saunders Date: Tue, 6 Aug 2024 11:52:12 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20more=20specific=20check=20for=20?= =?UTF-8?q?Grapher.useAdminAPI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/@ourworldindata/grapher/src/core/Grapher.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/@ourworldindata/grapher/src/core/Grapher.tsx b/packages/@ourworldindata/grapher/src/core/Grapher.tsx index 164b0e5eb54..ed0b5d920ee 100644 --- a/packages/@ourworldindata/grapher/src/core/Grapher.tsx +++ b/packages/@ourworldindata/grapher/src/core/Grapher.tsx @@ -858,7 +858,11 @@ export class Grapher */ @computed get useAdminAPI(): boolean { if (typeof window === "undefined") return false - return window.admin !== undefined + return ( + window.admin !== undefined && + // Ensure that we're not accidentally matching on a DOM element with an ID of "admin" + typeof window.admin.isSuperuser === "boolean" + ) } @computed get isUserLoggedInAsAdmin(): boolean {