This commit is contained in:
Brian Cao 2022-10-31 23:42:37 -07:00
parent 246e4e5f4f
commit 17041efaae
73 changed files with 491 additions and 874 deletions

View file

@ -1,5 +1,5 @@
import { parseSecureToken, parseToken } from 'next-basics';
import { getAccount, getWebsite } from 'queries';
import { getUser, getWebsite } from 'queries';
import { SHARE_TOKEN_HEADER, TYPE_ACCOUNT, TYPE_WEBSITE } from 'lib/constants';
import { secret } from 'lib/crypto';
@ -50,13 +50,13 @@ export async function allowQuery(req, type) {
if (userId) {
if (type === TYPE_WEBSITE) {
const website = await getWebsite({ websiteUuid: id });
const website = await getWebsite({ id });
return website && website.userId === userId;
} else if (type === TYPE_ACCOUNT) {
const account = await getAccount({ accountUuid: id });
const user = await getUser({ id });
return account && account.accountUuid === id;
return user && user.id === id;
}
}