diff --git a/package.json b/package.json index a1dee2b..93630b3 100644 --- a/package.json +++ b/package.json @@ -104,7 +104,7 @@ }, "dependencies": { "@babel/preset-env": "^7.23.9", - "@kinde-oss/kinde-typescript-sdk": "^2.8.0", + "@kinde-oss/kinde-typescript-sdk": "2.9.0", "cookie": "^0.6.0", "crypto-js": "^4.1.1", "jwt-decode": "^3.1.2", diff --git a/src/authMiddleware/authMiddleware.js b/src/authMiddleware/authMiddleware.js index af6d305..7c141ef 100644 --- a/src/authMiddleware/authMiddleware.js +++ b/src/authMiddleware/authMiddleware.js @@ -61,6 +61,7 @@ const handleMiddleware = async (req, options, onSuccess) => { } const accessTokenValue = jwt_decode(req.cookies.get('access_token').value); + const idTokenValue = jwt_decode(req.cookies.get('id_token')?.value); const isAuthorized = options?.isAuthorized ? options.isAuthorized({req, token: accessTokenValue}) @@ -69,7 +70,13 @@ const handleMiddleware = async (req, options, onSuccess) => { if (isAuthorized && onSuccess) { return await onSuccess({ token: accessTokenValue, - user: JSON.parse(req.cookies.get('user').value) + user: { + family_name: idTokenValue.family_name, + given_name: idTokenValue.given_name, + email: idTokenValue.email, + id: idTokenValue.sub, + picture: idTokenValue.picture + } }); } diff --git a/src/session/sessionManager.js b/src/session/sessionManager.js index 3f23a26..fb496e6 100644 --- a/src/session/sessionManager.js +++ b/src/session/sessionManager.js @@ -175,12 +175,14 @@ export const pageRouterSessionManager = (req, res) => { ]); }, destroySession: () => { - res?.setHeader('Set-Cookie', [ ...COOKIE_LIST.map((name) => - cookie.serialize(name, '', { - domain: config.cookieDomain ? config.cookieDomain : undefined, - maxAge: -1, - ...GLOBAL_COOKIE_OPTIONS - })) + res?.setHeader('Set-Cookie', [ + ...COOKIE_LIST.map((name) => + cookie.serialize(name, '', { + domain: config.cookieDomain ? config.cookieDomain : undefined, + maxAge: -1, + ...GLOBAL_COOKIE_OPTIONS + }) + ) ]); } }; diff --git a/src/utils/removeTrailingSlash.js b/src/utils/removeTrailingSlash.js index 670a18c..a26e5fa 100644 --- a/src/utils/removeTrailingSlash.js +++ b/src/utils/removeTrailingSlash.js @@ -1,5 +1,5 @@ export function removeTrailingSlash(url) { - if (url === undefined) return url; + if (url === undefined || url === null) return undefined; url = url.trim();