Fixed websites query.

This commit is contained in:
Mike Cao 2023-12-03 22:49:30 -08:00
parent 905b480c13
commit 66d7a815fc
3 changed files with 4 additions and 4 deletions

View File

@ -59,7 +59,7 @@ export async function canViewWebsite({ user, shareToken }: Auth, websiteId: stri
return !!(await findTeamWebsiteByUserId(websiteId, user.id)); return !!(await findTeamWebsiteByUserId(websiteId, user.id));
} }
export async function canViewAllWebsite({ user }: Auth) { export async function canViewAllWebsites({ user }: Auth) {
return user.isAdmin; return user.isAdmin;
} }

View File

@ -12,7 +12,7 @@ export function salt() {
return hash(secret(), ROTATING_SALT); return hash(secret(), ROTATING_SALT);
} }
export function uuid(...args: [any]) { export function uuid(...args: any) {
if (!args.length) return v4(); if (!args.length) return v4();
return v5(hash(...args, salt()), v5.DNS); return v5(hash(...args, salt()), v5.DNS);

View File

@ -1,4 +1,4 @@
import { canCreateWebsite, canViewAllWebsite } from 'lib/auth'; import { canCreateWebsite, canViewAllWebsites } from 'lib/auth';
import { uuid } from 'lib/crypto'; import { uuid } from 'lib/crypto';
import { useAuth, useCors, useValidate } from 'lib/middleware'; import { useAuth, useCors, useValidate } from 'lib/middleware';
import { NextApiRequestQueryBody, SearchFilter } from 'lib/types'; import { NextApiRequestQueryBody, SearchFilter } from 'lib/types';
@ -41,7 +41,7 @@ export default async (
} = req.auth; } = req.auth;
if (req.method === 'GET') { if (req.method === 'GET') {
if (canViewAllWebsite(req.auth)) { if (await canViewAllWebsites(req.auth)) {
const websites = getWebsites(req.query, { const websites = getWebsites(req.query, {
include: { include: {
teamWebsite: { teamWebsite: {