aboutsummaryrefslogtreecommitdiffstats
path: root/routes/payments.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-03-20 20:14:08 -0700
committerAdam Soltys <[email protected]>2023-03-20 20:14:08 -0700
commitc99665a0a0ac79176726169a49d5f9ebaae325bc (patch)
tree2ff3e55048dadc4a9afe88908dd8ae609aa1ad5b /routes/payments.js
parentcfca71ffceb3a462fc81919bd05ac33082935b46 (diff)
downloadcoinos-server-c99665a0a0ac79176726169a49d5f9ebaae325bc.tar.gz
coinos-server-c99665a0a0ac79176726169a49d5f9ebaae325bc.zip
prevent negative fees
Diffstat (limited to 'routes/payments.js')
-rw-r--r--routes/payments.js7
1 files changed, 5 insertions, 2 deletions
diff --git a/routes/payments.js b/routes/payments.js
index dfc8eeae..1a5bcf76 100644
--- a/routes/payments.js
+++ b/routes/payments.js
@@ -40,6 +40,7 @@ export default {
try {
amount = parseInt(amount);
maxfee = maxfee ? parseInt(maxfee) : 0;
+ if (maxfee < 0) fail("Max fee cannot be negative");
await requirePin({ body, user });
@@ -400,11 +401,12 @@ export default {
}
},
- async fix({ body: { uid }, user }, res) {
+ async fix({ body: { uid, username }, user }, res) {
try {
if (!user.admin) fail("unauthorized");
- let { username } = await g(`user:${uid}`);
+ if (username) uid = await g(`user:${username.toLowerCase()}`);
+ ({ username } = await g(`user:${uid}`));
let balance = await g(`balance:${uid}`);
let payments = await db.lRange(`${uid}:payments`, 0, -1);
@@ -420,6 +422,7 @@ export default {
await s(`balance:${uid}`, total);
res.send("ok");
} catch (e) {
+ console.log(e);
bail(res, e.message);
}
},