From 091716e037e3eb74259ca9ec91ff7b2e0ac46ff8 Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Sat, 12 Nov 2022 11:33:14 -0800 Subject: [PATCH] Updated middleware check. --- lib/middleware.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/middleware.js b/lib/middleware.js index 5660388e..09d790d1 100644 --- a/lib/middleware.js +++ b/lib/middleware.js @@ -26,11 +26,11 @@ export const useSession = createMiddleware(async (req, res, next) => { export const useAuth = createMiddleware(async (req, res, next) => { const token = getAuthToken(req); - const payload = parseSecureToken(token, secret()) || {}; + const payload = parseSecureToken(token, secret()); const shareToken = await parseShareToken(req); let user; - const { userId, key } = payload; + const { userId, key } = payload || {}; if (validate(userId)) { user = await getUser({ id: userId });