From edbb291628cfc5e0e2e628b5f5a3294f39154fd1 Mon Sep 17 00:00:00 2001 From: Francis Cao Date: Tue, 31 Mar 2026 15:15:39 -0700 Subject: [PATCH] fix undefined share params allowing access to pages --- src/app/share/ShareProvider.tsx | 3 ++- src/app/share/[slug]/[[...path]]/SharePage.tsx | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/app/share/ShareProvider.tsx b/src/app/share/ShareProvider.tsx index a09a3776e..60e989014 100644 --- a/src/app/share/ShareProvider.tsx +++ b/src/app/share/ShareProvider.tsx @@ -27,6 +27,7 @@ const ALL_SECTION_IDS = [ 'events', 'sessions', 'realtime', + 'performance', 'compare', 'breakdown', 'goals', @@ -59,7 +60,7 @@ export function ShareProvider({ slug, children }: { slug: string; children: Reac const isWebsiteShare = share?.shareType === ENTITY_TYPE.website; const allowedSections = isWebsiteShare && share?.parameters - ? ALL_SECTION_IDS.filter(id => share.parameters[id] !== false) + ? ALL_SECTION_IDS.filter(id => share.parameters[id] === true) : []; const shouldRedirect = isWebsiteShare && diff --git a/src/app/share/[slug]/[[...path]]/SharePage.tsx b/src/app/share/[slug]/[[...path]]/SharePage.tsx index a1103ffd9..750097aa1 100644 --- a/src/app/share/[slug]/[[...path]]/SharePage.tsx +++ b/src/app/share/[slug]/[[...path]]/SharePage.tsx @@ -23,7 +23,7 @@ import { useShare } from '@/components/hooks'; import { MobileMenuButton } from '@/components/input/MobileMenuButton'; import { ENTITY_TYPE } from '@/lib/constants'; import { Column, Grid, Row, useTheme } from '@umami/react-zen'; -import { usePathname } from 'next/navigation'; +import { usePathname, useRouter } from 'next/navigation'; import { useEffect, useState } from 'react'; import { ShareFooter } from './ShareFooter'; import { ShareNav } from './ShareNav'; @@ -69,9 +69,10 @@ export function SharePage() { }; const share = useShare(); const { setTheme } = useTheme(); + const router = useRouter(); const pathname = usePathname(); const path = getSharePath(pathname); - const { websiteId, boardId, pixelId, linkId, parameters = {}, shareType } = share; + const { slug, websiteId, boardId, pixelId, linkId, parameters = {}, shareType } = share; useEffect(() => { const url = new URL(window?.location?.href); @@ -102,9 +103,10 @@ export function SharePage() { // Check if the requested path is allowed const pageKey = path || ''; - const isAllowed = pageKey === '' || pageKey === 'overview' || parameters[pageKey] !== false; + const isAllowed = pageKey === '' || parameters[pageKey] === true; if (!isAllowed) { + router.replace(`/share/${slug}`); return null; }