Javascript Rule-Based Authentication

Move user metadata attributes to profile root attributes

What does it do?

This rule moves select data from usermetadata to profile root attributes (familyname, givenname, name, nickname and picture). Verify the field mapping before enabling this rule. The rule will determine if there is a mapped field on the usermetadata before the update. Important:

1- The rule updates the profile root attribute with the mapped field from usermetadata. 2- The mapped fields from usermetadata will be removed following the update. 3- This rule will be executed on each login event. For signup scenarios, you should only consider using this rule if you currently use a custom signup form or Authentication Signup API, as these signup methods do not support setting the root attributes.

How do I use it?

Just create a new rule in the Auth0 dashboard, and copy the following code replacing the placeholders with the appropriate values.

What is Rule-Based Authentication?

A rule is arbitrary JavaScript code that can be used to extend Auth0s default behavior when authenticating a user. Enabled rules will be executed in the order shown below for all users and applications as the final step of the authentication process.

Rules can be used to enrich and transform the user profile, deny access to specific users under certain conditions, retrieve information from external services and much more. For more information about rules, please check the documentation