Allow unrestricted access when share token has no section flags

This commit is contained in:
Mike Cao
2026-06-02 16:28:30 -07:00
parent ade0819be1
commit f366d946e8
+24
View File
@@ -18,6 +18,23 @@ export type ShareSection =
| 'revenue'
| 'attribution';
const SHARE_SECTIONS: ShareSection[] = [
'overview',
'events',
'sessions',
'realtime',
'performance',
'compare',
'breakdown',
'goals',
'funnels',
'journeys',
'retention',
'utm',
'revenue',
'attribution',
];
type ShareSectionInput = ShareSection | ShareSection[];
function shareTokenIncludesWebsite(auth: Auth | null | undefined, websiteId: string) {
@@ -46,6 +63,13 @@ export async function canViewWebsiteSection(
}
const sections = Array.isArray(section) ? section : [section];
const hasSectionParameters = SHARE_SECTIONS.some(
key => typeof shareToken.parameters?.[key] === 'boolean',
);
if (!hasSectionParameters) {
return true;
}
return sections.some(key => shareToken.parameters?.[key] === true);
}