Skip to content

Instantly share code, notes, and snippets.

@SevanBadal
Last active April 11, 2024 13:10
Show Gist options
  • Save SevanBadal/96af2bc5621bf556e59d06671e85442e to your computer and use it in GitHub Desktop.
Save SevanBadal/96af2bc5621bf556e59d06671e85442e to your computer and use it in GitHub Desktop.
username isn’t a standard OIDC claim. So the Auth0 Universal Form (w/username, email, and password fields) returns the local-part of the email as the nickname. This is inconvenient when the client is relying on username data after the form is submitted. One solution is to use a Pre User Registration Flow - setting nickname equal to username.
/**
* You can create PreUserRegistration flows in the Actions -> Flows menu in your Auth0 dashboard
*
* Handler that will be called during the execution of a PreUserRegistration flow.
*
* @param {Event} event - Details about the context and user that is attempting to register.
* @param {PreUserRegistrationAPI} api - Interface whose methods can be used to change the behavior of the signup.
*
*/
exports.onExecutePreUserRegistration = async (event, api) => {
api.user.setAppMetadata('nickname', event.user.username);
};
@Sonny949
Copy link

Thank you so much! This should really be fixed in auth0. Drove me insane.

@escherlies
Copy link

nice! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment