hi everyone,
i have a auth0 automation to add a role to a user to the first login. with the new updates the row
await management.assignRolestoUser(params, data);
no logner works, i cannot find any info with my search in the docs can anyone tell me how to do it now the code some month ago was working
the error is
TypeError: management.assignRolestoUser is not a function
here is the complete action
exports.onExecutePostLogin = async (event, api) => {
const result = event.transaction.redirect_uri === "site link";
console.log(result + " result of redirect uri " + event.transaction.redirect_uri);
if (event.stats.logins_count > 1) {
return;
}
if (event.transaction.redirect_uri === "site link") {
const ManagementClient = require('auth0').ManagementClient;
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" : [event.secrets.role]};
try {
await management.assignRolestoUser(params, data);
console.log(`Role ${data.roles} successfully assigned to ${event.user.email}`);
api.idToken.setCustomClaim(`rules`, "rangerGestUser");
api.accessToken.setCustomClaim(`rules`, "rangerGestUser");
} catch (err) {
console.log(err);
// Handle error.
}
}
};