diff options
| author | Adam Soltys <[email protected]> | 2026-03-01 21:09:20 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-03-01 21:09:20 -0800 |
| commit | 1649bfd6dc01e8bebccab97327db2d55addb8854 (patch) | |
| tree | 7a7e724b2663c520ab5b47d21c1ab862c2e859a0 | |
| parent | 5db704c583904a941e4a99f9c43fef2128207e92 (diff) | |
| download | coinos-server-1649bfd6dc01e8bebccab97327db2d55addb8854.tar.gz coinos-server-1649bfd6dc01e8bebccab97327db2d55addb8854.zip | |
delete endpoint
| -rw-r--r-- | index.ts | 1 | ||||
| -rw-r--r-- | routes/users.ts | 37 |
2 files changed, 38 insertions, 0 deletions
@@ -139,6 +139,7 @@ app.post("/ark/vault-send", auth, payments.arkVaultSend); app.post("/ark/vault-receive", auth, payments.arkVaultReceive); app.post("/account/delete", auth, users.deleteAccount); +app.post("/user/delete", auth, users.deleteUser); app.get("/account/:id", auth, users.account); app.post("/account/:id", auth, users.updateAccount); app.get("/accounts", auth, users.accounts); diff --git a/routes/users.ts b/routes/users.ts index 6869021a..bc899ac7 100644 --- a/routes/users.ts +++ b/routes/users.ts @@ -1050,6 +1050,43 @@ export default { } }, + async deleteUser(c) { + try { + const user = c.get("user"); + const { id, username, pubkey } = user; + l("deleteUser", username, id); + + // Remove app created during registration + const appKeys = await db.sMembers(`${id}:apps`); + const m = db.multi(); + for (const key of appKeys) { + m.del(`app:${key}`); + } + + // Reverse everything register() created + m.del(`user:${id}`) + .del(`user:${username}`) + .del(`account:${id}`) + .del(`${id}:accounts`) + .del(`${id}:apps`); + + if (pubkey) { + m.del(`user:${pubkey}`) + .del(`${pubkey}:follows:n`) + .del(`${pubkey}:followers:n`) + .del(`${pubkey}:pubkeys`); + } + + await m.exec(); + + l("deleted user", username); + return c.json({ ok: true }); + } catch (e) { + err("problem deleting user", e.message); + return bail(c, e.message); + } + }, + async flash(c) { const body = await c.req.json(); const { ssid, key, token } = body; |
