mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
Fixed links/pixel lookup.
This commit is contained in:
parent
895b41cb78
commit
5244d8608b
1 changed files with 10 additions and 6 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
import { Auth } from '@/lib/types';
|
import { Auth } from '@/lib/types';
|
||||||
import { PERMISSIONS } from '@/lib/constants';
|
import { PERMISSIONS } from '@/lib/constants';
|
||||||
import { hasPermission } from '@/lib/auth';
|
import { hasPermission } from '@/lib/auth';
|
||||||
import { getTeamUser, getWebsite } from '@/queries/prisma';
|
import { getLink, getPixel, 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) {
|
||||||
|
|
@ -13,17 +13,21 @@ export async function canViewWebsite({ user, shareToken }: Auth, websiteId: stri
|
||||||
}
|
}
|
||||||
|
|
||||||
const website = await getWebsite(websiteId);
|
const website = await getWebsite(websiteId);
|
||||||
|
const link = await getLink(websiteId);
|
||||||
|
const pixel = await getPixel(websiteId);
|
||||||
|
|
||||||
if (!website) {
|
const entity = website || link || pixel;
|
||||||
|
|
||||||
|
if (!entity) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (website.userId) {
|
if (entity.userId) {
|
||||||
return user.id === website.userId;
|
return user.id === entity.userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (website.teamId) {
|
if (entity.teamId) {
|
||||||
const teamUser = await getTeamUser(website.teamId, user.id);
|
const teamUser = await getTeamUser(entity.teamId, user.id);
|
||||||
|
|
||||||
return !!teamUser;
|
return !!teamUser;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue