Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

clean-up canViewWebsite, use getEntity

Francis Cao3fc41bdd089b
diff --git a/src/permissions/website.ts b/src/permissions/website.ts
index 97952eed9..4008449d0 100644
--- a/src/permissions/website.ts
+++ b/src/permissions/website.ts
@@ -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;