aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-02-10 05:13:04 +0000
committerAdam Soltys <[email protected]>2023-02-09 21:13:36 -0800
commit75ae71955c000ad9458c8f80c61a74a4aa3fb951 (patch)
tree49aef921c1c0440690a049f642eaaecd8a87c2b4
parenta9edfeb925b213b6a74c10daf358600e912aa8ce (diff)
downloadcoinos-server-75ae71955c000ad9458c8f80c61a74a4aa3fb951.tar.gz
coinos-server-75ae71955c000ad9458c8f80c61a74a4aa3fb951.zip
log missing payments
-rw-r--r--lib/auth.js18
-rw-r--r--lib/payments.js8
2 files changed, 16 insertions, 10 deletions
diff --git a/lib/auth.js b/lib/auth.js
index 9720cd83..f3cfd1e9 100644
--- a/lib/auth.js
+++ b/lib/auth.js
@@ -7,17 +7,17 @@ export const optional = {
preValidation: fastifyPassport.authenticate(
"jwt",
{ session: false },
- function(req, res, err, user, info) {
+ function (req, res, err, user, info) {
req.user = user;
}
- )
+ ),
};
export const auth = {
preValidation: fastifyPassport.authenticate("jwt", {
authInfo: false,
- session: false
- })
+ session: false,
+ }),
};
export const requirePin = async ({ body, user }) => {
@@ -29,9 +29,13 @@ export const jwtStrategy = new jwt.Strategy(
{
jwtFromRequest: jwt.ExtractJwt.fromExtractors([
jwt.ExtractJwt.fromAuthHeaderAsBearerToken(),
- req => (req.cookies ? req.cookies.token : null)
+ (req) => (req.cookies ? req.cookies.token : null),
]),
- secretOrKey: config.jwt
+ secretOrKey: config.jwt,
},
- async (payload, next) => next(null, await g(`user:${payload.id}`))
+ async (payload, next) => {
+ let user = await g(`user:${payload.id}`);
+ if (typeof user === "string") await g(`user:${user}`);
+ next(null, user);
+ }
);
diff --git a/lib/payments.js b/lib/payments.js
index 8806e6f8..2c0eb0c0 100644
--- a/lib/payments.js
+++ b/lib/payments.js
@@ -13,7 +13,7 @@ export const types = {
bitcoin: "bitcoin",
lightning: "lightning",
pot: "pot",
- classic: "classic"
+ classic: "classic",
};
export let debit = async (
@@ -66,7 +66,7 @@ export let debit = async (
currency,
type,
ref,
- created: Date.now()
+ created: Date.now(),
};
await s(`payment:${id}`, p);
@@ -98,7 +98,7 @@ export let credit = async (hash, amount, memo, ref, type = types.internal) => {
ref,
type,
confirmed: true,
- created: Date.now()
+ created: Date.now(),
};
let { tip } = invoice;
@@ -141,6 +141,8 @@ export let credit = async (hash, amount, memo, ref, type = types.internal) => {
export let confirm = async (address, txid, vout) => {
let id = `payment:${txid}:${vout}`;
let p = await g(id);
+ if (!p) return db.sAdd("missed", id);
+
p.confirmed = true;
await db