From 8f2d41cec860ef7d0ced1df1a397ed93bb119f2a Mon Sep 17 00:00:00 2001 From: gioelecerati <50955448+gioelecerati@users.noreply.github.com> Date: Wed, 27 Sep 2023 18:00:50 +0200 Subject: [PATCH] user: delete api (#1884) --- packages/api/src/controllers/user.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/packages/api/src/controllers/user.ts b/packages/api/src/controllers/user.ts index 180efdb5bc..e5582e1744 100644 --- a/packages/api/src/controllers/user.ts +++ b/packages/api/src/controllers/user.ts @@ -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,