Last active
April 11, 2024 13:10
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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); | |
}; |
Thank you so much! This should really be fixed in auth0. Drove me insane.
nice! 👍
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No problem! The other alternative that I've seen implemented uses the Auth0 Management API in server-side code to fetch the username at the start of a user session.