Changing user roles
# support-questions
hi all, I'm attempting to define a user role based on whether the user is in a list of emails, and the list could change over time. I see that I can assign a role on sign up (, but if a user is already signed in and their email is added to the list later on, I'd like to automatically assign the role and have it propagate to the frontend in a reasonable amount of time. Any suggestions on how to do that? I see that I can call
await session.fetchAndSetClaim(UserRoleClaim)
, but I'm not sure how to go from an email to a
Hey @lunis you can just update the roles of the user in the db and the change should be reflected on all their sessions within 5 mins (which is the default)
If you want that time to be shorter, you can add a maxAgeInSeconds param to a lower number when using the roles validator in your APIs.
got it, thanks!
oh, does that mean that
in the Node sdk would work since it'd propagate to the db and from there to the sessions?
@rp I'm adding the role in the post sign up override (, but in the access token,
is empty. If I sign back in a few minutes later, it contains the role. Is that just the 5 minute delay that you mentioned above? Is there any way to cause it to happen immediately on sign up?
I tried using getSession from inside consumeCodePOST, but that just caused me to get an error when clicking the passwordless sign in link
ah, I see that session is on the originalImplementation.consumeCodePOST response
yea.. you can use that session object to run
await session.fetchAndSetClaim(roles claim)