Skip to content

Commit

Permalink
Merge pull request #3854 from owid/smarter-grapher-admin-boolean
Browse files Browse the repository at this point in the history
🔨 more specific check for `Grapher.useAdminAPI`
  • Loading branch information
ikesau authored Aug 6, 2024
2 parents c24a48d + 47cb9b5 commit 70e5f8d
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 70e5f8d

Please sign in to comment.