Hi @greg.macwilliam ,
I’m afraid there isn’t a hook for a username change available currently like there is for a change in email, and that in turn is only available for Custom Databases in Legacy authentication mode.
However, assuming Auth0 is the IdP in your scenario, the only way to change a user’s username is to use the Management API’s “Update a user” PATCH endpoint. Therefore, you could integrate with the server side app/script making the PATCH call to also update your own database if the PATCH is successful to keep the two in sync.
If the username is coming from an upstream provider, you may want to turn off “Sync user profile attributes at each login” if you are making changes to username on the Auth0 side to avoid them being overwritten.
If on the other hand you are trying to detect changes upstream, then you may want to leverage ID tokens and/or the
/userinfo endpoint to check your database’s copy is up to date with the latest authentication the user performed on the connection.
You can also add custom claims to ID tokens if you need information not available in the standard OIDC claims. This will also update the responses returned by the