orszi7861
03/07/2022, 1:56 PMconst currAccessTokenPayload = req.session!.getAccessTokenPayload();
await req.session!.updateAccessTokenPayload({ newKey: 'newValue', ...currAccessTokenPayload });
and in frontend i cannot see it in the const { accessTokenPayload } = useSessionContext();
, but in the sAccessToken cookie it already isrp_st
03/07/2022, 1:58 PMupdateAccessTokenPayload
after sending a response already?orszi7861
03/07/2022, 2:02 PMrp_st
03/07/2022, 2:04 PMorszi7861
03/07/2022, 2:05 PMHTTP/1.1 400 Bad Request
X-Powered-By: Express
Access-Control-Allow-Origin: http://localhost:3001
Vary: Origin
Access-Control-Allow-Credentials: true
front-token: eyJ1aWQiOiJiY2QyMjhkYy0zNGNmLTQxMGYtYjdmZS1kMTc2MWE2YzcxZWEiLCJhdGUiOjE2NDY2NjU0NzY0OTgsInVwIjp7Im5ld0tleSI6Im5ld1ZhbHVlIiwiYXBwUGVybWlzc2lvbiI6IlBPUlRBTCJ9fQ==
Access-Control-Expose-Headers: front-token, front-token
Set-Cookie: sAccessToken=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsInZlcnNpb24iOiIyIn0%3D.eyJzZXNzaW9uSGFuZGxlIjoiYTBhOGNjMTAtMmY5MC00ODg0LTg2NDctNzM2MjcyMzIxOGI2IiwidXNlcklkIjoiYmNkMjI4ZGMtMzRjZi00MTBmLWI3ZmUtZDE3NjFhNmM3MWVhIiwicmVmcmVzaFRva2VuSGFzaDEiOiIxNjdhZTNhOWNiZGI1NzAzZTlhN2IwMDlkNTFjZmFmMDFmZGJkOTVkYWY1YjRiNjNhNTg1ZDI4YTM4MjNkNTNmIiwidXNlckRhdGEiOnsibmV3S2V5IjoibmV3VmFsdWUiLCJhcHBQZXJtaXNzaW9uIjoiUE9SVEFMIn0sImV4cGlyeVRpbWUiOjE2NDY2NjU0NzY0OTgsInRpbWVDcmVhdGVkIjoxNjQ2NjYxODc4NDUzLCJsbXJ0IjoxNjQ2NjYxODc4NDUwfQ%3D%3D.RDvXCbMz2oY1T075HjHz9BorCwz5K6vMIrSptmXrH9jPRe6DZj60ro%2Bx4IvsS2xwOUAtJctBaHceU7joOuf%2BxjzY0hApnr4JI12ia4nkLtCGVClxN5NpILlP1wdONLW3IpWue0egpSe1q8b3ByKBFMD%2BZW%2BegTMpkOOrmW2tdo911ORb0ObVfiO1cYqhBEgGXkfQstrX0bp5d%2B6AmszQ4vRXLkjGEbmeuGoPKIIr8hVC40vVtxzPxyQKtLYaYmdHCPbzo9DQR22F5vQaB6p1JCWSAcrX%2FnDOO8Is5Ktc6qshcUwsQMBjQLrKzgcAWlWI0%2BdKsjgdV2YO1BBApz9m4Q%3D%3D; Path=/; Expires=Mon, 07 Mar 2022 15:04:36 GMT; HttpOnly; SameSite=Lax
Content-Type: application/json; charset=utf-8
Content-Length: 132
ETag: W/"84-30Faf12mbQ8Q9dSFfQ8EhAQGhdc"
Date: Mon, 07 Mar 2022 14:04:38 GMT
Connection: keep-alive
Keep-Alive: timeout=5
rp_st
03/07/2022, 2:06 PMrp_st
03/07/2022, 2:07 PM{
"newKey": "newValue",
"appPermission": "PORTAL"
}
orszi7861
03/07/2022, 2:07 PMconst session = await createNewSession(
options.res,
user.id,
{
appPermission: 'PORTAL',
// res
},
{},
userContext,
);
and it is working as expectedorszi7861
03/07/2022, 2:08 PMrp_st
03/07/2022, 2:08 PMrp_st
03/07/2022, 2:08 PMorszi7861
03/07/2022, 2:09 PM"supertokens-auth-react": "^0.19.0",
rp_st
03/07/2022, 2:10 PMrp_st
03/07/2022, 2:11 PMawait Session.getAccessTokenPayloadSecurely()
and see what that returns? https://supertokens.com/docs/auth-react/modules/recipe_session.html#getAccessTokenPayloadSecurely-1orszi7861
03/07/2022, 2:20 PMappPermission: "PORTAL"
orszi7861
03/07/2022, 2:20 PMrp_st
03/07/2022, 2:26 PMSession.getAccessTokenPayloadSecurely()
reads from the storage layer directly. It should have given the updated result.rp_st
03/07/2022, 2:27 PMorszi7861
03/07/2022, 2:29 PMrp_st
03/07/2022, 2:34 PMSession.getAccessTokenPayloadSecurely()
should always give the latest value (As per my current testing). But there is an issue where the sessionContext is not updated when the access token payload is changed.rp_st
03/07/2022, 2:34 PMconsole.log(await Session.getAccessTokenPayloadSecurely());
and see if you are getting the older payload?rp_st
03/07/2022, 2:39 PMgetAccessTokenPayloadSecurely
(that should work).orszi7861
03/07/2022, 2:53 PMrp_st
03/07/2022, 2:55 PMorszi7861
03/07/2022, 3:00 PMrp_st
03/07/2022, 3:00 PMorszi7861
03/07/2022, 3:00 PMSuperTokens is an open source authentication solution offering features like: Different types of login: Email / password, Passwordless (OTP or Magic link based).
Powered by