Add sharing to pixel and link detail pages

This commit is contained in:
Mike Cao committed 2026-03-09 01:26:02 -07:00
1 parent c4226bc63d
commit 64bf4c378c
23 files changed
+582 -43

No files matched your search

+8 -4
View File
@@ -3,15 +3,19 @@ import { PERMISSIONS } from '@/lib/constants';
import type { Auth } from '@/lib/types';
import { getPixel, getTeamUser } from '@/queries/prisma';
export async function canViewPixel({ user }: Auth, pixelId: string) {
if (!user) {
return false;
export async function canViewPixel({ user, shareToken }: Auth, pixelId: string) {
if (user?.isAdmin) {
return true;
}
if (user.isAdmin) {
if (shareToken?.pixelId === pixelId || shareToken?.websiteId === pixelId) {
return true;
}
if (!user) {
return false;
}
const pixel = await getPixel(pixelId);
if (pixel.userId) {