Allow unrestricted access when share token has no section flags
This commit is contained in:
1 parent
ade0819be1
commit
f366d946e8
1 file changed
+24
@@ -18,6 +18,23 @@ export type ShareSection =
|
|||||||
| 'revenue'
|
| 'revenue'
|
||||||
| 'attribution';
|
| 'attribution';
|
||||||
|
|
||||||
|
const SHARE_SECTIONS: ShareSection[] = [
|
||||||
|
'overview',
|
||||||
|
'events',
|
||||||
|
'sessions',
|
||||||
|
'realtime',
|
||||||
|
'performance',
|
||||||
|
'compare',
|
||||||
|
'breakdown',
|
||||||
|
'goals',
|
||||||
|
'funnels',
|
||||||
|
'journeys',
|
||||||
|
'retention',
|
||||||
|
'utm',
|
||||||
|
'revenue',
|
||||||
|
'attribution',
|
||||||
|
];
|
||||||
|
|
||||||
type ShareSectionInput = ShareSection | ShareSection[];
|
type ShareSectionInput = ShareSection | ShareSection[];
|
||||||
|
|
||||||
function shareTokenIncludesWebsite(auth: Auth | null | undefined, websiteId: string) {
|
function shareTokenIncludesWebsite(auth: Auth | null | undefined, websiteId: string) {
|
||||||
@@ -46,6 +63,13 @@ export async function canViewWebsiteSection(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const sections = Array.isArray(section) ? section : [section];
|
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);
|
return sections.some(key => shareToken.parameters?.[key] === true);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user