Skip to content

Commit

Permalink
user: delete api (#1884)
Browse files Browse the repository at this point in the history
  • Loading branch information
gioelecerati authored Sep 27, 2023
1 parent 2d05e86 commit 8f2d41c
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions packages/api/src/controllers/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,23 @@ app.get("/:id", authorizer({ allowUnverified: true }), async (req, res) => {
res.json(cleanUserFields(user, req.user.admin));
});

app.delete("/:id", authorizer({ admin: true }), async (req, res) => {
const { id } = req.params;
const user = await db.user.get(id);
if (!user) {
res.status(404);
return res.json({ errors: ["user not found"] });
}
await db.user.delete(id);

// TODO: remove all streams owned by user
// TODO: remove all assets owned by user
// TODO: remove the stripe account

res.status(204);
res.end();
});

app.post("/", validatePost("user"), async (req, res) => {
const {
email,
Expand Down

0 comments on commit 8f2d41c

Please sign in to comment.