Skip to content

Commit

Permalink
impr(server): dont allow banned accounts to reset or delete their data
Browse files Browse the repository at this point in the history
  • Loading branch information
Miodec committed Apr 28, 2024
1 parent a57b6c2 commit bfe39c6
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions backend/src/api/controllers/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ export async function deleteUser(

const userInfo = await UserDAL.getUser(uid, "delete user");

if (userInfo.banned) {
throw new MonkeyError(403, "Banned users cannot delete their account");
}

//cleanup database
await Promise.all([
UserDAL.deleteUser(uid),
Expand Down Expand Up @@ -211,6 +215,10 @@ export async function resetUser(
const { uid } = req.ctx.decodedToken;

const userInfo = await UserDAL.getUser(uid, "reset user");
if (userInfo.banned) {
throw new MonkeyError(403, "Banned users cannot reset their account");
}

const promises = [
UserDAL.resetUser(uid),
deleteAllApeKeys(uid),
Expand Down

0 comments on commit bfe39c6

Please sign in to comment.