Hi.
I have created a rule to assign a default role at the moment that users make signup.
i followed http://community.auth0.com/t/how-do-i-add-a-default-role-to-a-new-user-on-first-login/25857 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": [
"[rol_1lcv9FwvpVPRIeMA]"
]
};
request.post({
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.