Hey Folks!
I’m having an issue where I need to have the name at sign up, I already did the additional field in lock (snippet down), then I need to update the root attribute for name, using that additional field. The problem I’m facing is that I’m not able to get that additional field in the rule, whithin user_metadata
nor app_metadata
after sign up.
Any help is welcome.
Additional Filed Snippet:
additionalSignUpFields: [{
name: “full_name”,
placeholder: “Enter your full name”,
validator: function (name) {
return {
valid: name.length !== 0,
hint: “Please fill your name”
}
}
}]
Rule snippet:
function addUserNameRootAttrs(user, context, callback) {
user.user_metadata = user.user_metadata || {};
console.log('Users\'s object: ', user);
console.log('Users\'s context object: ', context);
if (user.user_metadata.profile.name !== user.name) {
var ManagementClient = require('auth0@2.23.0”').ManagementClient;
var management = new ManagementClient({
clientId: configuration.AUTH0_CLIENT_ID,
clientSecret: configuration.AUTH0_SECRET,
domain: configuration.AUTH0_DOMAIN,
scopes: ['update:profile'],
});
var params = { id: user.user_id };
var data = { name: user.user_metadata.profile.name };
management.users.update(params, data, function (err, user) {
if (err) {
throw err;
}
console.log('New Profile: ', user);
callback(null, user, context);
});
}
callback(null, user, context);
}
Thanks!