From b8d121656146d26004c1fa2d98948acdf10b789d Mon Sep 17 00:00:00 2001 From: Peter Phanouvong Date: Wed, 6 Dec 2023 14:37:53 +1000 Subject: [PATCH] fix: decode the accessTokenValue --- src/authMiddleware/authMiddleware.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/authMiddleware/authMiddleware.js b/src/authMiddleware/authMiddleware.js index ae284db..0ae7845 100644 --- a/src/authMiddleware/authMiddleware.js +++ b/src/authMiddleware/authMiddleware.js @@ -49,13 +49,10 @@ const handleMiddleware = async (req, options, onSuccess) => { config.redirectURL ) ); - response.headers.set('x-hello-from-middleware2', 'hello'); return response; } - const accessTokenValue = JSON.parse( - req.cookies.get('access_token_payload').value - ); + const accessTokenValue = jwt_decode(req.cookies.get('access_token').value); const isAuthorized = options?.isAuthorized({req, token: accessTokenValue}) ?? @@ -63,7 +60,7 @@ const handleMiddleware = async (req, options, onSuccess) => { if (isAuthorized && onSuccess) { return await onSuccess({ - token: JSON.parse(req.cookies.get('access_token_payload').value), + token: accessTokenValue, user: JSON.parse(req.cookies.get('user').value) }); }