Sanitize eventdata.

This commit is contained in:
Brian Cao 2023-01-17 21:59:14 -08:00
parent 509739fc9a
commit e6a6222088
3 changed files with 35 additions and 12 deletions

View file

@ -10,17 +10,21 @@ export default async (req, res) => {
const { id: websiteUuid } = req.query;
if (!(await allowQuery(req, TYPE_WEBSITE, false))) {
return unauthorized(res);
}
if (req.method === 'GET') {
if (!(await allowQuery(req, TYPE_WEBSITE))) {
return unauthorized(res);
}
const website = await getWebsite({ websiteUuid });
return ok(res, website);
}
if (req.method === 'POST') {
if (!(await allowQuery(req, TYPE_WEBSITE, false))) {
return unauthorized(res);
}
const { name, domain, owner, enableShareUrl, shareId } = req.body;
const { accountUuid } = req.auth;
@ -58,6 +62,10 @@ export default async (req, res) => {
}
if (req.method === 'DELETE') {
if (!(await allowQuery(req, TYPE_WEBSITE, false))) {
return unauthorized(res);
}
await deleteWebsite(websiteUuid);
return ok(res);