clean-up canViewWebsite, use getEntity

This commit is contained in:
Francis Cao 2026-01-22 16:37:53 -08:00
parent f4eaa9fd0d
commit 3fc41bdd08

View file

@ -1,7 +1,8 @@
import { hasPermission } from '@/lib/auth';
import { PERMISSIONS } from '@/lib/constants';
import { getEntity } from '@/lib/entity';
import type { Auth } from '@/lib/types';
import { getLink, getPixel, getTeamUser, getWebsite } from '@/queries/prisma';
import { getTeamUser, getWebsite } from '@/queries/prisma';
export async function canViewWebsite({ user, shareToken }: Auth, websiteId: string) {
if (user?.isAdmin) {
@ -12,11 +13,7 @@ export async function canViewWebsite({ user, shareToken }: Auth, websiteId: stri
return true;
}
const website = await getWebsite(websiteId);
const link = await getLink(websiteId);
const pixel = await getPixel(websiteId);
const entity = website || link || pixel;
const entity = await getEntity(websiteId);
if (!entity) {
return false;