Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

fix undefined share params allowing access to pages

Francis Caoedbb291628cf
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;
}