Bailey
12/13/2022, 8:08 PMverified
in the access token payload which is set during session creation. At a later time when I want to update this value for all sessions with a given userId, I am doing the following:
async function updateAllAccessTokenPayloads(uuid, data) {
const handles = await getAllSessionHandlesForUser(uuid);
for (let i = 0; i < handles?.length; i++) {
await mergeIntoAccessTokenPayload(handles[i], data);
}
}
On the frontend, I'm getting inconsistent results:
After calling mergeIntoAccessTokenPayload
on each session handle, it doesn't always update the session on the frontend. I noticed that after refreshing the page in Chrome, the supertokens api /session/refresh
is called every time. But not in other browsers (Edge, Firefox).
This /session/refresh
call causes the frontend to cycle through 2-3 JWTs, some with the correct verified
value, some unchanged. In Firefox/Edge, the /session/refresh
call doesn't happen on a page refresh, and it seems to be unaffected by the mergeIntoAccessTokenPayload
call.
I'm continuing with testing to better understand what's happening, but I'm wondering if there's anything wrong with my use of mergeIntoAccessTokenPayload
. Should these session changes be reflected in the useSessionContext()
token payload on the frontend after a page refresh?
Edit: Until the frontend automatically calls /session/refresh
, the frontend is using an out of date token payload. After calling session/refresh
, it has the updated payload.rp_st
12/14/2022, 2:41 AMrp_st
12/14/2022, 2:42 AMrp_st
12/14/2022, 2:42 AMrp_st
12/14/2022, 2:43 AMBailey
12/14/2022, 3:01 PM/session/refresh
is called, but this is only occurring in chrome and it shouldn't be calling it on a page reload. What could cause the frontend to call /session/refresh
?rp_st
12/14/2022, 3:02 PMrp_st
12/14/2022, 3:03 PMrp_st
12/14/2022, 3:04 PMBailey
12/14/2022, 3:36 PMBailey
12/14/2022, 3:36 PMrp_st
12/14/2022, 3:37 PMrp_st
12/14/2022, 3:37 PMBailey
12/14/2022, 3:43 PMBailey
12/14/2022, 3:46 PMrp_st
12/14/2022, 3:46 PMrp_st
12/14/2022, 3:48 PMrp_st
12/14/2022, 3:48 PMrp_st
12/14/2022, 3:49 PMBailey
12/14/2022, 3:59 PMrp_st
12/14/2022, 3:59 PMrp_st
12/14/2022, 4:00 PMrp_st
12/14/2022, 4:00 PMBailey
12/14/2022, 4:01 PMrp_st
12/14/2022, 4:02 PMBailey
12/14/2022, 4:55 PM/session/refresh
is called, and also /user/email/verify
. I'm not sure why the verify route is being called.Bailey
12/14/2022, 4:57 PMBailey
12/14/2022, 5:01 PM/user/email/verify
automatically, but I'm not sure why this API would be called.Bailey
12/14/2022, 5:22 PM/session/refresh
, so mergeIntoAccessTokenPayload
isn't intended to update the frontend when the merge request is made, but instead when a new access token is generated? It seems like I have an unrelated issue I'm going to try to debug, but the merge function isn't going to address the issue I was trying to solve.
Is there a method to update all frontend token payloads for a user without having to wait for their existing token to expire?rp_st
12/14/2022, 5:56 PMrp_st
12/14/2022, 5:57 PMrp_st
12/14/2022, 5:58 PMBailey
12/14/2022, 5:59 PMfrontend: "supertokens-auth-react": "^0.27.1"
backend: "supertokens-node": "^12.1.0"
rp_st
12/14/2022, 6:00 PMrp_st
12/14/2022, 6:00 PMBailey
12/14/2022, 6:01 PMrp_st
12/14/2022, 6:02 PMrp_st
12/14/2022, 6:02 PMrp_st
12/14/2022, 6:02 PMrp_st
12/14/2022, 6:02 PMrp_st
12/14/2022, 6:02 PMrp_st
12/14/2022, 6:02 PMBailey
12/14/2022, 6:04 PMrp_st
12/14/2022, 6:05 PMBailey
12/14/2022, 6:05 PMrp_st
12/14/2022, 6:05 PMrp_st
12/14/2022, 6:05 PMBailey
12/14/2022, 6:06 PMrp_st
12/14/2022, 6:07 PMrp_st
12/14/2022, 6:07 PMBailey
12/14/2022, 6:10 PMapp.disable('etag');
seems to be working as intended.Bailey
12/14/2022, 6:10 PMrp_st
12/14/2022, 6:11 PMBailey
12/14/2022, 6:12 PMrp_st
12/14/2022, 6:13 PM