diff options
| author | Adam Soltys <[email protected]> | 2025-09-18 16:51:06 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2025-09-18 16:51:06 -0700 |
| commit | 3d933408542d5176af53afe111a98c06ff80c076 (patch) | |
| tree | 5bc5e9a9c09ca358e91fc55e4e4ca8a5d61736d3 | |
| parent | 1347f87dcd92d318fbdd9d364648bc32ee52b4a7 (diff) | |
| download | coinos-server-3d933408542d5176af53afe111a98c06ff80c076.tar.gz coinos-server-3d933408542d5176af53afe111a98c06ff80c076.zip | |
fail if unauthorized
| -rw-r--r-- | routes/invoices.ts | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/routes/invoices.ts b/routes/invoices.ts index 7e98599e..3cc6bab0 100644 --- a/routes/invoices.ts +++ b/routes/invoices.ts @@ -54,15 +54,18 @@ export default { const { id } = req.params; const { body } = req; const { tip, webhook, secret } = body.invoice; - if (tip == null || tip < 0) fail("Invalid tip"); + + if (tip < 0) fail("Invalid tip"); let invoice = await g(`invoice:${id}`); const user = req.user || (await g(`user:${invoice.uid}`)); - if (tip) invoice.tip = tip; - if (invoice.uid === user?.id) { - if (webhook) invoice.webhook = webhook; - if (secret) invoice.secret = secret; + if (typeof tip !== "undefined") invoice.tip = tip; + + if (webhook && secret) { + if (invoice.uid !== user?.id) fail("Unauthorized"); + invoice.webhook = webhook; + invoice.secret = secret; } invoice = await generate({ invoice, user }); |
