diff --git a/src/handlers/pageRouter/callback.js b/src/handlers/pageRouter/callback.js index 40b91f9..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'); @@ -32,12 +33,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: '/'