Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

Commit

Permalink
fix account delete bug
Browse files Browse the repository at this point in the history
  • Loading branch information
briancao committed Nov 1, 2022
1 parent e558192 commit 3a617b7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pages/api/accounts/[id]/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
}
}

Expand All @@ -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);
}
Expand Down

0 comments on commit 3a617b7

Please sign in to comment.