Hi, I'm having trouble updating the access token payload for multiple sessions. I have variable call...
b

Bailey

over 2 years ago
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.
Hey there supertokens community 👋 I stumbled upon supertokens and am pretty excited to use it in a...
d

deezy5456

over 2 years ago
Hey there supertokens community 👋 I stumbled upon supertokens and am pretty excited to use it in a side project of mine! TL;DR:
getRoutingComponent()
does not render in chrome extension, but does when run via
npm start
or
npm run build && serve -s {{path}}
My current project involves a chrome extension running a react app in its popup. It is in this react app that I would like users to register or login using supertokens. To this end, I followed your getting started guide. As a minimal example, I simply initialize
SuperTokens
and call
getRoutingComponent()
, which IIUC, returns an element that renders the login/registration UI. That being said, when I use
npm start
or
npm run build && serve -s {{path}},
I do see the login UI being rendered. When turning on debug logs and logging the return value of
getRoutingComponent()
, I do see
SuperTokens
being initialized as well as the return value of the function call not being
null
. Instead, I can see it is of type
react.element
with a props
path
of
index.html
and
supertokensInstance
being the supertokens instance. This led me to the conclusion that soemthing's wrong with my configuration since it's working with both the devserver and as a production build being served. I've searched for similar use cases and indeed found some who were using supertokens in a chrome extension but nothing comparable here