aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-02-06 16:42:02 -0800
committerAdam Soltys <[email protected]>2023-02-06 16:42:02 -0800
commit6f5602d112b68adb7452abf3047f20c32e7725b6 (patch)
tree640903158751d97954cec7b8687f1aa88079305f
parentf4c51cddc3d6c45fa1de5fd928b1b2a0f95774f8 (diff)
downloadcoinos-server-6f5602d112b68adb7452abf3047f20c32e7725b6.tar.gz
coinos-server-6f5602d112b68adb7452abf3047f20c32e7725b6.zip
auth middleware for disable2fa
-rw-r--r--docker-compose.yml2
-rw-r--r--index.js2
-rw-r--r--routes/payments.js12
-rw-r--r--routes/users.js4
4 files changed, 10 insertions, 10 deletions
diff --git a/docker-compose.yml b/docker-compose.yml
index 70d12c24..9958458f 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -72,4 +72,4 @@ services:
- "./data/nostr/data:/usr/src/app/db"
- "./data/nostr/config.toml:/usr/src/app/config.toml"
ports:
- - '8080:8080'
+ - '8082:8080'
diff --git a/index.js b/index.js
index 9e380334..da7e6319 100644
--- a/index.js
+++ b/index.js
@@ -65,7 +65,7 @@ app.post("/bitcoin/send", auth, payments.send);
app.get("/me", auth, users.me);
app.get("/users/:key", users.get);
app.post("/register", users.create);
-app.post("/disable2fa", users.disable2fa);
+app.post("/disable2fa", auth, users.disable2fa);
app.post("/2fa", auth, users.enable2fa);
app.post("/user", auth, users.update);
app.post("/upload/:type", auth, users.upload);
diff --git a/routes/payments.js b/routes/payments.js
index 37f4c953..1043959c 100644
--- a/routes/payments.js
+++ b/routes/payments.js
@@ -240,19 +240,19 @@ export default {
res.send({ txid });
},
- async del({ params: { username }, headers: { authorization }}, res) {
-if (!authorization.includes(config.admin)) return res.code(401).send("unauthorized")
+ async del({ params: { username }, headers: { authorization } }, res) {
+ if (!authorization.includes(config.admin))
+ return res.code(401).send("unauthorized");
let { id, pubkey } = await g(`user:${await g(`user:${username}`)}`);
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}`);
+ 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:${id}`);
db.del(`user:${pubkey}`);
res.send({});
- }
+ }
};
-
diff --git a/routes/users.js b/routes/users.js
index 4fcc50df..17d4e1da 100644
--- a/routes/users.js
+++ b/routes/users.js
@@ -134,7 +134,7 @@ export default {
if (user.pin && !(pin === user.pin)) throw new Error("Pin required");
if (typeof newpin !== "undefined") user.pin = newpin;
- if (!user.pin) user.pin = null;
+ if (!user.pin || user.pin === "undefined") delete user.pin;
let exists;
if (username) exists = await g(`user:${username}`);
@@ -237,7 +237,7 @@ export default {
if (!p.with) continue;
let id = await g(`user:${p.with.username}`);
- let u = id && await g(`user:${id}`);
+ let u = id && (await g(`user:${id}`));
if (!u) {
u = await got(`${classic}/admin/migrate/${p.with.username}`, {