From e1beafc2c1add04495fe31475aa344c5219e525c Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sun, 16 Apr 2023 18:14:36 +0000 Subject: ip and lnurl fixes --- routes/lnurl.js | 1 + routes/users.js | 18 ++---------------- 2 files changed, 3 insertions(+), 16 deletions(-) (limited to 'routes') diff --git a/routes/lnurl.js b/routes/lnurl.js index bcb3f234..5cfb26bb 100644 --- a/routes/lnurl.js +++ b/routes/lnurl.js @@ -92,6 +92,7 @@ export default { let uid = await g(`lnurl:${id}`); let user = await g(`user:${uid}`); let { username } = user; + username = username.replace(/\s/g, '').toLowerCase(); let metadata = JSON.stringify([ ["text/plain", `Paying ${username}@${host}`], diff --git a/routes/users.js b/routes/users.js index e82a6772..70dce4d5 100644 --- a/routes/users.js +++ b/routes/users.js @@ -125,7 +125,7 @@ export default { async create(req, res) { try { - const ip = req.headers["x-forwarded-for"] || req.socket.remoteAddress; + const ip = req.headers["cf-connecting-ip"] || req.socket.remoteAddress; let { cipher, pubkey, password, username, salt } = req.body.user; let user = { @@ -443,21 +443,7 @@ export default { }, async fix(req, res) { - if (!req.user.admin) fail("unauthorized"); - let uid = await g("user:laughingbean"); - let payments = await db.lRange(`${uid}:payments`, 0, -1); - - for (let hash of payments) { - let payment = await g(`payment:${hash}`); - let invoice = await g(`invoice:${hash}`); - if (!invoice) continue; - if (invoice.amount !== payment.amount) { - payment.amount -= payment.tip; - s(`payment:${hash}`, payment); - } - } - - res.send("ok"); + res.send(req.headers); }, async reset({ body: { username, password }, user: { admin } }, res) { -- cgit v1.2.3