Use token authentication for API requests.

This commit is contained in:
Mike Cao 2020-09-17 22:52:20 -07:00
parent bff8806b61
commit 96bd7e5b47
34 changed files with 198 additions and 153 deletions

View file

@ -15,21 +15,21 @@ export default async (req, res) => {
if (website_id) {
const website = await getWebsiteById(website_id);
if (website.user_id === user_id || is_admin) {
let { share_id } = website;
if (enable_share_url) {
share_id = share_id ? share_id : getRandomChars(8);
} else {
share_id = null;
}
await updateWebsite(website_id, { name, domain, share_id });
return ok(res);
if (website.user_id !== user_id && !is_admin) {
return unauthorized(res);
}
return unauthorized(res);
let { share_id } = website;
if (enable_share_url) {
share_id = share_id ? share_id : getRandomChars(8);
} else {
share_id = null;
}
await updateWebsite(website_id, { name, domain, share_id });
return ok(res);
} else {
const website_uuid = uuid();
const share_id = enable_share_url ? getRandomChars(8) : null;