mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
clean-up canViewWebsite, use getEntity
This commit is contained in:
parent
f4eaa9fd0d
commit
3fc41bdd08
1 changed files with 3 additions and 6 deletions
|
|
@ -1,7 +1,8 @@
|
||||||
import { hasPermission } from '@/lib/auth';
|
import { hasPermission } from '@/lib/auth';
|
||||||
import { PERMISSIONS } from '@/lib/constants';
|
import { PERMISSIONS } from '@/lib/constants';
|
||||||
|
import { getEntity } from '@/lib/entity';
|
||||||
import type { Auth } from '@/lib/types';
|
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) {
|
export async function canViewWebsite({ user, shareToken }: Auth, websiteId: string) {
|
||||||
if (user?.isAdmin) {
|
if (user?.isAdmin) {
|
||||||
|
|
@ -12,11 +13,7 @@ export async function canViewWebsite({ user, shareToken }: Auth, websiteId: stri
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const website = await getWebsite(websiteId);
|
const entity = await getEntity(websiteId);
|
||||||
const link = await getLink(websiteId);
|
|
||||||
const pixel = await getPixel(websiteId);
|
|
||||||
|
|
||||||
const entity = website || link || pixel;
|
|
||||||
|
|
||||||
if (!entity) {
|
if (!entity) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue