aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/countries.js2
-rw-r--r--lib/sockets.js4
-rw-r--r--routes/lnurl.js1
-rw-r--r--routes/users.js18
4 files changed, 7 insertions, 18 deletions
diff --git a/lib/countries.js b/lib/countries.js
index 4d5a48dc..9e1ecddb 100644
--- a/lib/countries.js
+++ b/lib/countries.js
@@ -34,7 +34,7 @@ export default {
BI: "BDI",
KH: "KHM",
CM: "CMR",
- CA: "CAN",
+ CA: "CAD",
IC: "EUR",
CV: "CVE",
KY: "KYD",
diff --git a/lib/sockets.js b/lib/sockets.js
index e5f2638b..c42c9c7a 100644
--- a/lib/sockets.js
+++ b/lib/sockets.js
@@ -49,17 +49,19 @@ export const broadcast = (type, data) => {
let track = async (ws, token) => {
let { id } = ws;
let { id: uid } = jwt.decode(token);
+
if (!uid) throw new Error("Invalid JWT token");
let user = await g(`user:${uid}`);
if (!user) throw new Error("User not found");
if (!store.sockets[uid]) store.sockets[uid] = {};
- if (store.sockets[uid][id]) return;
+
const existing = Object.keys(store.sockets[uid]);
if (existing.length > 4) {
const p = existing.find(sid => sid !== uid);
store.sockets[uid][p].close(code, "too many sockets");
}
+
store.sockets[uid][id] = ws;
users[id] = uid;
ws.user = user;
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) {