aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-02-10 13:16:39 -0800
committerAdam Soltys <[email protected]>2023-02-10 13:16:39 -0800
commit940b04615053b46e2f91ae076fd6d7b17edcab9a (patch)
tree5684268f50cd652eac7a3ee393caeb2d167d39ed
parent10f4606eead3bb5e899c7b5ab091c124338904f1 (diff)
downloadcoinos-server-940b04615053b46e2f91ae076fd6d7b17edcab9a.tar.gz
coinos-server-940b04615053b46e2f91ae076fd6d7b17edcab9a.zip
lowercase usernames
-rw-r--r--lib/invoices.js2
-rw-r--r--lib/register.js2
-rw-r--r--routes/lnurl.js2
-rw-r--r--routes/users.js11
4 files changed, 8 insertions, 9 deletions
diff --git a/lib/invoices.js b/lib/invoices.js
index bab48515..86d48bd8 100644
--- a/lib/invoices.js
+++ b/lib/invoices.js
@@ -19,7 +19,7 @@ export let generate = async ({ invoice, user, sender, memo }) => {
if (tip > 5 * amount || tip < 0) fail("tip amount out of range");
if (!user) user = sender;
- let uid = await g(`user:${user.username}`);
+ let uid = await g(`user:${user.username.toLowerCase()}`);
user = await g(`user:${uid}`);
if (!user) fail("user not provided");
diff --git a/lib/register.js b/lib/register.js
index ea86fbae..135bc041 100644
--- a/lib/register.js
+++ b/lib/register.js
@@ -17,7 +17,7 @@ export default async (user, ip, requireChallenge) => {
let id = v4();
user.id = id;
- let exists = await g(`user:${username}`);
+ let exists = await g(`user:${username.toLowerCase()}`);
if (exists) throw new Error(`Username ${username} taken`);
if (password) {
diff --git a/routes/lnurl.js b/routes/lnurl.js
index 638c827f..fb2b8744 100644
--- a/routes/lnurl.js
+++ b/routes/lnurl.js
@@ -34,7 +34,7 @@ export default {
},
async lnurlp({ params: { username } }, res) {
- let uid = await g(`user:${username}`);
+ let uid = await g(`user:${username.toLowerCase()}`);
if (!uid) {
let u = await got(`${classic}/admin/migrate/${username}?zero=true`, {
headers: { authorization: `Bearer ${admin}` }
diff --git a/routes/users.js b/routes/users.js
index d0b374dc..2cdd3247 100644
--- a/routes/users.js
+++ b/routes/users.js
@@ -369,13 +369,13 @@ export default {
if (!(authorization && authorization.includes(config.admin)))
return res.code(401).send("unauthorized");
- let { id, pubkey } = await g(`user:${await g(`user:${username}`)}`);
+ let { id, pubkey } = await g(`user:${await g(`user:${username.toLowerCase()}`)}`);
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:${username.toLowerCase()}`);
db.del(`user:${id}`);
db.del(`user:${pubkey}`);
@@ -383,10 +383,9 @@ export default {
},
async lower(req, res) {
- for await (let k of db.scanIterator({ MATCH: "user:*" })) {
- let u = await g(k);
- await db.del(k);
- await s(k.toLowerCase(), u);
+ for await (let k of db.scanIterator({ MATCH: "balance:*" })) {
+ let b = await g(k);
+ if (b < 0) console.log(k, b)
}
res.send("ok");