Add sharing to pixel and link detail pages
This commit is contained in:
1 parent
c4226bc63d
commit
64bf4c378c
23 files changed
+582
-43
No files matched your search
@@ -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) {
|
||||
|
||||
Reference in new issue
Block a user