From 75ae71955c000ad9458c8f80c61a74a4aa3fb951 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Fri, 10 Feb 2023 05:13:04 +0000 Subject: log missing payments --- lib/auth.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'lib/auth.js') 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); + } ); -- cgit v1.2.3