fix sharetoken permissions for pixels,links,boards, and failed routes

This commit is contained in:
Francis Cao committed 2026-06-08 19:16:01 -07:00
1 parent d2eafd68f7
commit 2df051e216
35 files changed
+308 -145

No files matched your search

@@ -3,7 +3,7 @@ import { parseEventPropertyFilters } from '@/lib/params';
import { getQueryFilters, parseRequest } from '@/lib/request';
import { json, unauthorized } from '@/lib/response';
import { filterParams, timezoneParam, unitParam } from '@/lib/schema';
import { canViewAuthenticatedWebsite } from '@/permissions';
import { canViewWebsiteSection } from '@/permissions';
import { getEventDataArraySeries } from '@/queries/sql/events/getEventDataArraySeries';
export async function GET(
@@ -28,7 +28,7 @@ export async function GET(
const { websiteId } = await params;
if (!(await canViewAuthenticatedWebsite(auth, websiteId))) {
if (!(await canViewWebsiteSection(auth, websiteId, 'events'))) {
return unauthorized();
}
@@ -3,7 +3,7 @@ import { parseEventPropertyFilters } from '@/lib/params';
import { getQueryFilters, parseRequest } from '@/lib/request';
import { json, unauthorized } from '@/lib/response';
import { filterParams, timezoneParam } from '@/lib/schema';
import { canViewAuthenticatedWebsite } from '@/permissions';
import { canViewWebsiteSection } from '@/permissions';
import { getEventDataDateSeries } from '@/queries/sql/events/getEventDataDateSeries';
export async function GET(
@@ -27,7 +27,7 @@ export async function GET(
const { websiteId } = await params;
if (!(await canViewAuthenticatedWebsite(auth, websiteId))) {
if (!(await canViewWebsiteSection(auth, websiteId, 'events'))) {
return unauthorized();
}
@@ -3,7 +3,7 @@ import { parseEventPropertyFilters } from '@/lib/params';
import { getQueryFilters, parseRequest } from '@/lib/request';
import { json, unauthorized } from '@/lib/response';
import { filterParams, timezoneParam, unitParam } from '@/lib/schema';
import { canViewAuthenticatedWebsite } from '@/permissions';
import { canViewWebsiteSection } from '@/permissions';
import { getEventDataNumericSeries } from '@/queries/sql/events/getEventDataNumericSeries';
export async function GET(
@@ -29,7 +29,7 @@ export async function GET(
const { websiteId } = await params;
if (!(await canViewAuthenticatedWebsite(auth, websiteId))) {
if (!(await canViewWebsiteSection(auth, websiteId, 'events'))) {
return unauthorized();
}
@@ -3,7 +3,7 @@ import { parseEventPropertyFilters } from '@/lib/params';
import { getQueryFilters, parseRequest } from '@/lib/request';
import { json, unauthorized } from '@/lib/response';
import { filterParams } from '@/lib/schema';
import { canViewAuthenticatedWebsite } from '@/permissions';
import { canViewWebsiteSection } from '@/permissions';
import { getEventDataNumericStats } from '@/queries/sql/events/getEventDataNumericStats';
export async function GET(
@@ -26,7 +26,7 @@ export async function GET(
const { websiteId } = await params;
if (!(await canViewAuthenticatedWebsite(auth, websiteId))) {
if (!(await canViewWebsiteSection(auth, websiteId, 'events'))) {
return unauthorized();
}
@@ -3,7 +3,7 @@ import { parseEventPropertyFilters } from '@/lib/params';
import { getQueryFilters, parseRequest } from '@/lib/request';
import { json, unauthorized } from '@/lib/response';
import { filterParams, timezoneParam, unitParam } from '@/lib/schema';
import { canViewAuthenticatedWebsite } from '@/permissions';
import { canViewWebsiteSection } from '@/permissions';
import { getEventDataPropertySeries } from '@/queries/sql/events/getEventDataPropertySeries';
export async function GET(
@@ -28,7 +28,7 @@ export async function GET(
const { websiteId } = await params;
if (!(await canViewAuthenticatedWebsite(auth, websiteId))) {
if (!(await canViewWebsiteSection(auth, websiteId, 'events'))) {
return unauthorized();
}
@@ -3,7 +3,7 @@ import { parseEventPropertyFilters } from '@/lib/params';
import { getQueryFilters, parseRequest } from '@/lib/request';
import { json, unauthorized } from '@/lib/response';
import { filterParams, pagingParams, timezoneParam, unitParam } from '@/lib/schema';
import { canViewAuthenticatedWebsite } from '@/permissions';
import { canViewWebsiteSection } from '@/permissions';
import { getEventDataPivot } from '@/queries/sql/events/getEventDataPivot';
export async function GET(
@@ -28,7 +28,7 @@ export async function GET(
const { websiteId } = await params;
if (!(await canViewAuthenticatedWebsite(auth, websiteId))) {
if (!(await canViewWebsiteSection(auth, websiteId, 'events'))) {
return unauthorized();
}
@@ -1,6 +1,6 @@
import { parseRequest } from '@/lib/request';
import { json, unauthorized } from '@/lib/response';
import { canViewAuthenticatedWebsite } from '@/permissions';
import { canViewWebsiteSection } from '@/permissions';
import { getEventDataById } from '@/queries/sql/events/getEventDataById';
export async function GET(
@@ -15,7 +15,7 @@ export async function GET(
const { websiteId, eventId } = await params;
if (!(await canViewAuthenticatedWebsite(auth, websiteId))) {
if (!(await canViewWebsiteSection(auth, websiteId, 'events'))) {
return unauthorized();
}
@@ -2,7 +2,7 @@ import { z } from 'zod';
import { getQueryFilters, parseRequest } from '@/lib/request';
import { json, unauthorized } from '@/lib/response';
import { filterParams } from '@/lib/schema';
import { canViewAuthenticatedWebsite } from '@/permissions';
import { canViewWebsiteSection } from '@/permissions';
import { getEventDataEvents } from '@/queries/sql/events/getEventDataEvents';
export async function GET(
@@ -23,7 +23,7 @@ export async function GET(
const { websiteId } = await params;
if (!(await canViewAuthenticatedWebsite(auth, websiteId))) {
if (!(await canViewWebsiteSection(auth, websiteId, 'events'))) {
return unauthorized();
}
@@ -2,7 +2,7 @@ import { z } from 'zod';
import { getQueryFilters, parseRequest } from '@/lib/request';
import { json, unauthorized } from '@/lib/response';
import { filterParams } from '@/lib/schema';
import { canViewAuthenticatedWebsite } from '@/permissions';
import { canViewWebsiteSection } from '@/permissions';
import { getEventDataFields } from '@/queries/sql';
export async function GET(
@@ -23,7 +23,7 @@ export async function GET(
const { websiteId } = await params;
if (!(await canViewAuthenticatedWebsite(auth, websiteId))) {
if (!(await canViewWebsiteSection(auth, websiteId, 'events'))) {
return unauthorized();
}
@@ -2,7 +2,7 @@ import { z } from 'zod';
import { getQueryFilters, parseRequest } from '@/lib/request';
import { json, unauthorized } from '@/lib/response';
import { filterParams } from '@/lib/schema';
import { canViewAuthenticatedWebsite } from '@/permissions';
import { canViewWebsiteSection } from '@/permissions';
import { getEventDataProperties } from '@/queries/sql';
export async function GET(
@@ -23,7 +23,7 @@ export async function GET(
const { websiteId } = await params;
if (!(await canViewAuthenticatedWebsite(auth, websiteId))) {
if (!(await canViewWebsiteSection(auth, websiteId, 'events'))) {
return unauthorized();
}
@@ -2,7 +2,7 @@ import { z } from 'zod';
import { getQueryFilters, parseRequest } from '@/lib/request';
import { json, unauthorized } from '@/lib/response';
import { filterParams, pagingParams } from '@/lib/schema';
import { canViewAuthenticatedWebsite } from '@/permissions';
import { canViewWebsiteSection } from '@/permissions';
import { getEventData } from '@/queries/sql/events/getEventData';
export async function GET(
@@ -24,7 +24,7 @@ export async function GET(
const { websiteId } = await params;
if (!(await canViewAuthenticatedWebsite(auth, websiteId))) {
if (!(await canViewWebsiteSection(auth, websiteId, 'events'))) {
return unauthorized();
}
@@ -2,7 +2,7 @@ import { z } from 'zod';
import { getQueryFilters, parseRequest } from '@/lib/request';
import { json, unauthorized } from '@/lib/response';
import { filterParams } from '@/lib/schema';
import { canViewAuthenticatedWebsite } from '@/permissions';
import { canViewWebsiteSection } from '@/permissions';
import { getEventDataStats } from '@/queries/sql';
export async function GET(
@@ -23,7 +23,7 @@ export async function GET(
const { websiteId } = await params;
if (!(await canViewAuthenticatedWebsite(auth, websiteId))) {
if (!(await canViewWebsiteSection(auth, websiteId, 'events'))) {
return unauthorized();
}
@@ -2,7 +2,7 @@ import { z } from 'zod';
import { getQueryFilters, parseRequest } from '@/lib/request';
import { json, unauthorized } from '@/lib/response';
import { filterParams } from '@/lib/schema';
import { canViewAuthenticatedWebsite } from '@/permissions';
import { canViewWebsiteSection } from '@/permissions';
import { getEventDataValues } from '@/queries/sql';
export async function GET(
@@ -26,7 +26,7 @@ export async function GET(
const { websiteId } = await params;
if (!(await canViewAuthenticatedWebsite(auth, websiteId))) {
if (!(await canViewWebsiteSection(auth, websiteId, 'events'))) {
return unauthorized();
}
@@ -2,7 +2,7 @@ import { z } from 'zod';
import { parseRequest } from '@/lib/request';
import { json, notFound, ok, unauthorized } from '@/lib/response';
import { anyObjectParam, segmentTypeParam } from '@/lib/schema';
import { canDeleteWebsite, canUpdateWebsite, canViewAuthenticatedWebsite } from '@/permissions';
import { canDeleteWebsite, canUpdateWebsite, canViewSharedWebsiteFilters } from '@/permissions';
import { deleteSegment, getWebsiteSegment, updateSegment } from '@/queries/prisma';
export async function GET(
@@ -17,7 +17,7 @@ export async function GET(
const { websiteId, segmentId } = await params;
if (!(await canViewAuthenticatedWebsite(auth, websiteId))) {
if (!(await canViewSharedWebsiteFilters(auth, websiteId))) {
return unauthorized();
}
@@ -3,7 +3,7 @@ import { uuid } from '@/lib/crypto';
import { getQueryFilters, parseRequest } from '@/lib/request';
import { json, unauthorized } from '@/lib/response';
import { searchParams, segmentParamSchema, segmentTypeParam } from '@/lib/schema';
import { canUpdateWebsite, canViewAuthenticatedWebsite } from '@/permissions';
import { canUpdateWebsite, canViewSharedWebsiteFilters } from '@/permissions';
import { createSegment, getWebsiteSegments } from '@/queries/prisma';
export async function GET(
@@ -24,7 +24,7 @@ export async function GET(
const { websiteId } = await params;
const { type } = query;
if (websiteId && !(await canViewAuthenticatedWebsite(auth, websiteId))) {
if (websiteId && !(await canViewSharedWebsiteFilters(auth, websiteId))) {
return unauthorized();
}
@@ -3,7 +3,7 @@ import { parsePropertyFilters } from '@/lib/params';
import { getQueryFilters, parseRequest } from '@/lib/request';
import { json, unauthorized } from '@/lib/response';
import { filterParams, pagingParams, timezoneParam, unitParam } from '@/lib/schema';
import { canViewAuthenticatedWebsite } from '@/permissions';
import { canViewWebsiteSection } from '@/permissions';
import { getSessionDataPivot } from '@/queries/sql/sessions/getSessionDataPivot';
export async function GET(
@@ -28,7 +28,7 @@ export async function GET(
const { websiteId } = await params;
if (!(await canViewAuthenticatedWebsite(auth, websiteId))) {
if (!(await canViewWebsiteSection(auth, websiteId, 'sessions'))) {
return unauthorized();
}
@@ -3,7 +3,7 @@ import { parsePropertyFilters } from '@/lib/params';
import { getQueryFilters, parseRequest } from '@/lib/request';
import { json, unauthorized } from '@/lib/response';
import { filterParams, timezoneParam, unitParam } from '@/lib/schema';
import { canViewAuthenticatedWebsite } from '@/permissions';
import { canViewWebsiteSection } from '@/permissions';
import { getSessionDataArraySeries } from '@/queries/sql';
export async function GET(
@@ -27,7 +27,7 @@ export async function GET(
const { websiteId } = await params;
if (!(await canViewAuthenticatedWebsite(auth, websiteId))) {
if (!(await canViewWebsiteSection(auth, websiteId, 'sessions'))) {
return unauthorized();
}
@@ -3,7 +3,7 @@ import { parsePropertyFilters } from '@/lib/params';
import { getQueryFilters, parseRequest } from '@/lib/request';
import { json, unauthorized } from '@/lib/response';
import { filterParams, timezoneParam } from '@/lib/schema';
import { canViewAuthenticatedWebsite } from '@/permissions';
import { canViewWebsiteSection } from '@/permissions';
import { getSessionDataDateSeries } from '@/queries/sql';
export async function GET(
@@ -26,7 +26,7 @@ export async function GET(
const { websiteId } = await params;
if (!(await canViewAuthenticatedWebsite(auth, websiteId))) {
if (!(await canViewWebsiteSection(auth, websiteId, 'sessions'))) {
return unauthorized();
}
@@ -3,7 +3,7 @@ import { parsePropertyFilters } from '@/lib/params';
import { getQueryFilters, parseRequest } from '@/lib/request';
import { json, unauthorized } from '@/lib/response';
import { filterParams, timezoneParam, unitParam } from '@/lib/schema';
import { canViewAuthenticatedWebsite } from '@/permissions';
import { canViewWebsiteSection } from '@/permissions';
import { getSessionDataNumericSeries } from '@/queries/sql';
export async function GET(
@@ -28,7 +28,7 @@ export async function GET(
const { websiteId } = await params;
if (!(await canViewAuthenticatedWebsite(auth, websiteId))) {
if (!(await canViewWebsiteSection(auth, websiteId, 'sessions'))) {
return unauthorized();
}
@@ -3,7 +3,7 @@ import { parsePropertyFilters } from '@/lib/params';
import { getQueryFilters, parseRequest } from '@/lib/request';
import { json, unauthorized } from '@/lib/response';
import { filterParams, timezoneParam } from '@/lib/schema';
import { canViewAuthenticatedWebsite } from '@/permissions';
import { canViewWebsiteSection } from '@/permissions';
import { getSessionDataNumericStats } from '@/queries/sql';
export async function GET(
@@ -26,7 +26,7 @@ export async function GET(
const { websiteId } = await params;
if (!(await canViewAuthenticatedWebsite(auth, websiteId))) {
if (!(await canViewWebsiteSection(auth, websiteId, 'sessions'))) {
return unauthorized();
}
@@ -3,7 +3,7 @@ import { parsePropertyFilters } from '@/lib/params';
import { getQueryFilters, parseRequest } from '@/lib/request';
import { json, unauthorized } from '@/lib/response';
import { filterParams } from '@/lib/schema';
import { canViewAuthenticatedWebsite } from '@/permissions';
import { canViewWebsiteSection } from '@/permissions';
import { getSessionDataProperties } from '@/queries/sql';
export async function GET(
@@ -25,7 +25,7 @@ export async function GET(
const { websiteId } = await params;
if (!(await canViewAuthenticatedWebsite(auth, websiteId))) {
if (!(await canViewWebsiteSection(auth, websiteId, 'sessions'))) {
return unauthorized();
}
@@ -3,7 +3,7 @@ import { parsePropertyFilters } from '@/lib/params';
import { getQueryFilters, parseRequest } from '@/lib/request';
import { json, unauthorized } from '@/lib/response';
import { filterParams, timezoneParam, unitParam } from '@/lib/schema';
import { canViewAuthenticatedWebsite } from '@/permissions';
import { canViewWebsiteSection } from '@/permissions';
import { getSessionDataPropertySeries } from '@/queries/sql';
export async function GET(
@@ -27,7 +27,7 @@ export async function GET(
const { websiteId } = await params;
if (!(await canViewAuthenticatedWebsite(auth, websiteId))) {
if (!(await canViewWebsiteSection(auth, websiteId, 'sessions'))) {
return unauthorized();
}
@@ -3,7 +3,7 @@ import { parsePropertyFilters } from '@/lib/params';
import { getQueryFilters, parseRequest } from '@/lib/request';
import { json, unauthorized } from '@/lib/response';
import { filterParams, timezoneParam, unitParam } from '@/lib/schema';
import { canViewAuthenticatedWebsite } from '@/permissions';
import { canViewWebsiteSection } from '@/permissions';
import { getSessionDataActivityStats } from '@/queries/sql/sessions/getSessionDataActivityStats';
export async function GET(
@@ -27,7 +27,7 @@ export async function GET(
const { websiteId } = await params;
if (!(await canViewAuthenticatedWebsite(auth, websiteId))) {
if (!(await canViewWebsiteSection(auth, websiteId, 'sessions'))) {
return unauthorized();
}
@@ -2,7 +2,7 @@ import { z } from 'zod';
import { getQueryFilters, parseRequest } from '@/lib/request';
import { json, unauthorized } from '@/lib/response';
import { filterParams } from '@/lib/schema';
import { canViewAuthenticatedWebsite } from '@/permissions';
import { canViewWebsiteSection } from '@/permissions';
import { getSessionDataValues } from '@/queries/sql';
export async function GET(
@@ -25,7 +25,7 @@ export async function GET(
const { websiteId } = await params;
if (!(await canViewAuthenticatedWebsite(auth, websiteId))) {
if (!(await canViewWebsiteSection(auth, websiteId, 'sessions'))) {
return unauthorized();
}
@@ -1,7 +1,7 @@
import { z } from 'zod';
import { getQueryFilters, parseRequest } from '@/lib/request';
import { json, unauthorized } from '@/lib/response';
import { canViewAuthenticatedWebsite } from '@/permissions';
import { canViewWebsiteSection } from '@/permissions';
import { getSessionActivity } from '@/queries/sql';
export async function GET(
@@ -21,7 +21,14 @@ export async function GET(
const { websiteId, sessionId } = await params;
if (!(await canViewAuthenticatedWebsite(auth, websiteId))) {
if (
!(await canViewWebsiteSection(auth, websiteId, [
'sessions',
'events',
'realtime',
'revenue',
]))
) {
return unauthorized();
}
@@ -1,6 +1,6 @@
import { parseRequest } from '@/lib/request';
import { json, unauthorized } from '@/lib/response';
import { canViewAuthenticatedWebsite } from '@/permissions';
import { canViewWebsiteSection } from '@/permissions';
import { getSessionData } from '@/queries/sql';
export async function GET(
@@ -15,7 +15,14 @@ export async function GET(
const { websiteId, sessionId } = await params;
if (!(await canViewAuthenticatedWebsite(auth, websiteId))) {
if (
!(await canViewWebsiteSection(auth, websiteId, [
'sessions',
'events',
'realtime',
'revenue',
]))
) {
return unauthorized();
}
@@ -1,6 +1,6 @@
import { parseRequest } from '@/lib/request';
import { json, unauthorized } from '@/lib/response';
import { canViewAuthenticatedWebsite } from '@/permissions';
import { canViewWebsiteSection } from '@/permissions';
import { getWebsiteSession } from '@/queries/sql';
export async function GET(
@@ -15,7 +15,14 @@ export async function GET(
const { websiteId, sessionId } = await params;
if (!(await canViewAuthenticatedWebsite(auth, websiteId))) {
if (
!(await canViewWebsiteSection(auth, websiteId, [
'sessions',
'events',
'realtime',
'revenue',
]))
) {
return unauthorized();
}
@@ -24,7 +24,7 @@ export async function GET(
const { websiteId } = await params;
if (!(await canViewWebsiteSection(auth, websiteId, 'sessions'))) {
if (!(await canViewWebsiteSection(auth, websiteId, ['overview', 'sessions']))) {
return unauthorized();
}