From 19480e0c07632b645fbee881dcbc3bf41c481eed Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Mon, 13 Feb 2023 21:04:02 +0000 Subject: check payload id --- lib/auth.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/auth.js b/lib/auth.js index 2e26f138..0533de31 100644 --- a/lib/auth.js +++ b/lib/auth.js @@ -34,8 +34,12 @@ export const jwtStrategy = new jwt.Strategy( secretOrKey: config.jwt }, async (payload, next) => { - let user = await g(`user:${payload.id}`); - if (typeof user === "string") await g(`user:${user}`); + let user; + if (payload.id) { + user = await g(`user:${payload.id}`); + if (typeof user === "string") await g(`user:${user}`); + } + next(null, user); } ); -- cgit v1.2.3