Given our following rule:
function (user, context, callback) {
var uuid = require("uuid");
user.app_metadata = user.app_metadata || {};
var promise = Promise.resolve(1);
if (!user.app_metadata.uuid) {
user.app_metadata.uuid = uuid();
promise = auth0.users.updateAppMetadata(user.user_id, user.app_metadata);
}
promise.then(() => {
if (context.idToken) {
// Include the uuid in the issued ID token if applicable
context.idToken["https://www.ourcompany.com/auth0-uuid"] = user.app_metadata.uuid;
}
if (context.accessToken) {
// Include the uuid in the issued access token if applicable
context.accessToken["https://www.ourcompany.com/uuid"] = user.app_metadata.uuid;
}
callback(null, user, context);
}).catch(callback);
}
This rule is only executed when logging in via our Angular application. I like to be able to use this rule when I create a new user via the Management API. Now I understood from the documentation this is not possible because the rule is not called. I can confirm this because after having created some users, none of them have the required UUID.
The reason is I like to automatically create users for webload testing. Suppose I create 50 users, I need to manually log in every time to initialize the UUID in the claims. Of course this would be a 1 time operation, but I rather like to automate this.
Is there a solution to my problem? I read about converting rules to actions, but it is not clear if this is a solution.