How to assign a default role to user at signup?

I have created a rule to assign a default role at the moment that users make signup.
i followed and i put the next code in the rule:

function setDefaultRole(user, context, callback) {
    var request = require("request");

    var count = context.stats && context.stats.loginsCount ? context.stats.loginsCount : 0;
    if (count > 1) {
        return callback(null, user, context);

    var headers = {
        'Authorization': 'Bearer ' + auth0.accessToken,
 const data = {
        "roles": [
        url: `https://${auth0.domain}/api/v2/users/${user.user_id}/roles`,
        headers: headers,
        json: data
    }, (err, response, body) => {
        return callback(new Error("Can not update users with role"));

    callback(null, user, context);

If i see the logs, the events that appears are:
1- Success signup
2 - Failed login (because of email verification needed to login)
3 - Succes Verification Email
4 - Success login (Login intent after user email verification)
5 - Success Exhange (because of user authorization of exhange data in presence of localhost development URL)

As you can see, it seems like the rule is not called or executed (even though the rule is enabled).
What is wrong??

Thanks in advance.

Hi @orozcox,

Can you add some console log to establish that the rule is being called?

Let me know what happens,

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.