Hi, I'm having trouble updating the access token payload for multiple sessions. I have variable called
verified
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.