aboutsummaryrefslogtreecommitdiffstats
path: root/routes/users.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-02-03 21:25:52 +0000
committerAdam Soltys <[email protected]>2023-02-03 13:26:51 -0800
commitf4c51cddc3d6c45fa1de5fd928b1b2a0f95774f8 (patch)
tree911c6d2064b1ad386318c09435ab99ad054a9996 /routes/users.js
parent17a2a698de2a522f05d9ec813411b5a01b95234d (diff)
downloadcoinos-server-f4c51cddc3d6c45fa1de5fd928b1b2a0f95774f8.tar.gz
coinos-server-f4c51cddc3d6c45fa1de5fd928b1b2a0f95774f8.zip
delete user endpoint
Diffstat (limited to 'routes/users.js')
-rw-r--r--routes/users.js20
1 files changed, 19 insertions, 1 deletions
diff --git a/routes/users.js b/routes/users.js
index 10cc358d..4fcc50df 100644
--- a/routes/users.js
+++ b/routes/users.js
@@ -237,7 +237,8 @@ export default {
if (!p.with) continue;
let id = await g(`user:${p.with.username}`);
- let u = await g(`user:${id}`);
+ let u = id && await g(`user:${id}`);
+
if (!u) {
u = await got(`${classic}/admin/migrate/${p.with.username}`, {
headers: { authorization: `Bearer ${config.admin}` }
@@ -372,5 +373,22 @@ export default {
await s(`${id}:contacts`, contacts);
res.send(contacts);
+ },
+
+ async del({ params: { username }, headers: { authorization } }, res) {
+ if (!(authorization && authorization.includes(config.admin)))
+ return res.code(401).send("unauthorized");
+
+ let { id, pubkey } = await g(`user:${await g(`user:${username}`)}`);
+ let invoices = await db.lRange(`${id}:invoices`, 0, -1);
+ let payments = await db.lRange(`${id}:payments`, 0, -1);
+
+ for (let { id } of invoices) db.del(`invoice:${id}`);
+ for (let { id } of payments) db.del(`payment:${id}`);
+ db.del(`user:${username}`);
+ db.del(`user:${id}`);
+ db.del(`user:${pubkey}`);
+
+ res.send({});
}
};