Skip to main content

Updating roles in a session

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

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