aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2025-03-13 16:08:52 -0700
committerAdam Soltys <[email protected]>2025-03-13 16:08:52 -0700
commit37d4f46c24532150654bc5e14c4cf7b16d822712 (patch)
treec6218b74d63123c5f8e3dbfa37f1cad785fc7f54
parent48001868b418c500d96801bf31b5f7b5c4f4d79c (diff)
downloadcoinos-server-37d4f46c24532150654bc5e14c4cf7b16d822712.tar.gz
coinos-server-37d4f46c24532150654bc5e14c4cf7b16d822712.zip
account check
-rw-r--r--routes/payments.ts3
-rw-r--r--routes/users.ts8
2 files changed, 11 insertions, 0 deletions
diff --git a/routes/payments.ts b/routes/payments.ts
index 4d1c55c5..ec342dc4 100644
--- a/routes/payments.ts
+++ b/routes/payments.ts
@@ -268,6 +268,9 @@ export default {
amount = parseInt(amount);
if (amount < 0) fail("Invalid amount");
+ const managers = await db.sMembers(`fund:${id}:managers`);
+ if (managers.length && !managers.includes(user.id)) fail("Unauthorized");
+
const result: any = await db.debit(`fund:${id}`, "", amount, 0, 0, 0);
if (result.err) fail(result.err);
diff --git a/routes/users.ts b/routes/users.ts
index ab8cb61a..8fb078e1 100644
--- a/routes/users.ts
+++ b/routes/users.ts
@@ -769,8 +769,12 @@ export default {
async updateAccount(req, res) {
const { id } = req.params;
+ const { id: uid } = req.user;
const { name } = req.body;
+ const pos = await db.lPos(`${uid}:accounts`, id);
+ if (!pos) fail("account not found");
+
const account = await g(`account:${id}`);
account.name = name;
await s(`account:${id}`, account);
@@ -783,6 +787,10 @@ export default {
const { id } = req.body;
const { id: uid } = req.user;
const { type } = await g(`account:${id}`);
+
+ const pos = await db.lPos(`${uid}:accounts`, id);
+ if (!(type && pos)) fail("account not found");
+
try {
const node = rpc({ ...config[type], wallet: id });
await node.unloadWallet(id);