From 912ad3b54a2fad10e6bad60453b43ec8261a479a Mon Sep 17 00:00:00 2001 From: Dave Berner Date: Thu, 31 Aug 2023 11:41:35 +1000 Subject: [PATCH 1/2] fix: define payload --- src/handlers/pageRouter/callback.js | 3 ++- src/utils/pageRouter/isTokenValid.js | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/handlers/pageRouter/callback.js b/src/handlers/pageRouter/callback.js index 40b91f9..bac10be 100644 --- a/src/handlers/pageRouter/callback.js +++ b/src/handlers/pageRouter/callback.js @@ -32,12 +32,13 @@ export const callback = async (req, res) => { ); const data = await response.json(); + const accessToken = jwt_decode(data.access_token); if (isTokenValid(data)) { res.setHeader( 'Set-Cookie', cookie.serialize(`kinde_token`, JSON.stringify(data), { httpOnly: true, - expires: new Date(accessTokenPayload.exp * 1000), + expires: new Date(accessToken.exp * 1000), sameSite: 'lax', secure: config.redirectURL.substring(0, 6) == 'https:', path: '/' diff --git a/src/utils/pageRouter/isTokenValid.js b/src/utils/pageRouter/isTokenValid.js index 71051a5..0ad5535 100644 --- a/src/utils/pageRouter/isTokenValid.js +++ b/src/utils/pageRouter/isTokenValid.js @@ -1,5 +1,6 @@ import jwt_decode from 'jwt-decode'; import {config} from '../../config/index'; +import jwt_decode from 'jwt-decode'; const isTokenValid = (token) => { const accessToken = (token && token.access_token) || token; From c612fcbe06a24d6d0254909b617fe76952174404 Mon Sep 17 00:00:00 2001 From: Dave Berner Date: Thu, 31 Aug 2023 11:44:37 +1000 Subject: [PATCH 2/2] fix: jwt decode dep --- src/handlers/pageRouter/callback.js | 1 + src/utils/pageRouter/isTokenValid.js | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/handlers/pageRouter/callback.js b/src/handlers/pageRouter/callback.js index bac10be..edd50db 100644 --- a/src/handlers/pageRouter/callback.js +++ b/src/handlers/pageRouter/callback.js @@ -1,6 +1,7 @@ import {config} from '../../config/index'; import {isTokenValid} from '../../utils/pageRouter/isTokenValid'; import {version} from '../../utils/version'; +import jwt_decode from 'jwt-decode'; var cookie = require('cookie'); diff --git a/src/utils/pageRouter/isTokenValid.js b/src/utils/pageRouter/isTokenValid.js index 0ad5535..71051a5 100644 --- a/src/utils/pageRouter/isTokenValid.js +++ b/src/utils/pageRouter/isTokenValid.js @@ -1,6 +1,5 @@ import jwt_decode from 'jwt-decode'; import {config} from '../../config/index'; -import jwt_decode from 'jwt-decode'; const isTokenValid = (token) => { const accessToken = (token && token.access_token) || token;