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 { 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 JWT payload    // that you may have provided earlier.    await req.session.updateJWTPayload(        {role}    );