Hey @ali4, thanks for the additional info, and sorry for inconvenience - Perhaps you can try the code from a post login action? I tested on my end by adding code to hit the management API to add a role to a newly registered user:
exports.onExecutePostUserRegistration = async (event) => {
const ManagementClient = require('auth0').ManagementClient;
//initialize management client
const management = new ManagementClient({
domain: event.secrets.domain,
clientId: event.secrets.clientID,
clientSecret: event.secrets.clientSecret,
});
const params = { id : event.user.user_id};
const data = { "roles" : ["rol_id"]};
try {
const res = await management.assignRolestoUser(params, data)
} catch (e) {
console.log(e)
// Handle error
console.log("there was an error :(")
}
};
If you want to try this, you can find some more on using the node management client in an action here:
Let us know!