Merge remote-tracking branch 'origin/app' into dev

This commit is contained in:
Mike Cao 2022-10-31 20:21:19 -07:00
commit 5d73a9c4b4
4 changed files with 70 additions and 9 deletions

View file

@ -43,7 +43,7 @@ export default async (req, res) => {
const accountByUsername = await getAccount({ username });
if (accountByUsername) {
return badRequest(res, 'Account already exists');
return badRequest(res, 'Account already exists.');
}
}
@ -53,11 +53,15 @@ export default async (req, res) => {
}
if (req.method === 'DELETE') {
if (id === userId) {
return badRequest(res, 'You cannot delete your own account.');
}
if (!isAdmin) {
return unauthorized(res);
}
await deleteAccount(userId);
await deleteAccount(+id);
return ok(res);
}

View file

@ -23,6 +23,7 @@ export default async (req, res) => {
if (req.method === 'POST') {
const { name, domain, owner, enableShareUrl, shareId } = req.body;
const { accountUuid } = req.auth;
let account;
if (accountUuid) {
@ -43,7 +44,7 @@ export default async (req, res) => {
name,
domain,
shareId: shareId ? shareId : newShareId,
userId: account ? account.id : +owner || undefined,
userId: +owner || account.id,
},
{ websiteUuid },
);