From 283ffc9d8442ecbbc85c0c40167cc03f20f64a40 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sat, 28 Jan 2023 00:54:08 -0800 Subject: parse ints --- lib/invoices.js | 4 +++- lib/upload.js | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/invoices.js b/lib/invoices.js index f17223aa..814e87d9 100644 --- a/lib/invoices.js +++ b/lib/invoices.js @@ -12,9 +12,11 @@ import ln from "$lib/ln"; export let generate = async ({ invoice, user, sender }) => { let { currency, tip, amount, rate, request_id, type } = invoice; + amount = parseInt(amount); + tip = parseInt(tip || 0); + if (amount < 0) fail("amount out of range"); if (tip > 5 * amount || tip < 0) fail("tip amount out of range"); - tip = tip || 0; if (!user) user = sender; let uid = await g(`user:${user.username}`); diff --git a/lib/upload.js b/lib/upload.js index 5f5aebed..2f8180a0 100644 --- a/lib/upload.js +++ b/lib/upload.js @@ -12,6 +12,7 @@ export default async (req, res) => { params: { type }, user } = req; + console.log("TYPE", type) if (!["banner", "profile"].includes(type)) throw new Error("invalid upload"); let data = await req.file(); -- cgit v1.2.3