clean-up canViewWebsite, use getEntity
This commit is contained in:
1 parent
f4eaa9fd0d
commit
3fc41bdd08
1 file changed
+3
-6
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user