Skip to content

Commit

Permalink
🔨 more specific check for Grapher.useAdminAPI
Browse files Browse the repository at this point in the history
  • Loading branch information
ikesau committed Aug 6, 2024
1 parent bc66a38 commit 47cb9b5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/@ourworldindata/grapher/src/core/Grapher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 47cb9b5

Please sign in to comment.