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.

Allow unrestricted access when share token has no section flags

Mike Caof366d946e85e
diff --git a/src/permissions/share.ts b/src/permissions/share.ts
index d75d2b1eb..1d22e8dda 100644
--- a/src/permissions/share.ts
+++ b/src/permissions/share.ts
@@ -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);
}