Skip to main content

Updating roles in a session

This can only be done on the backend by using the updateAccessTokenPayload function post session verification:

let { verifySession } = require("supertokens-node/recipe/session/framework/express");"/update-role", verifySession(), async (req, res) => {
    let userId = req.session.getUserId(); 
    let role = "newRole"; // TODO: fetch based on user
    // Note that this will override any existing access token payload    // that you may have provided earlier.    await req.session.updateAccessTokenPayload(        {role}    );