Changing user_id values for custom database users

Problem statement

We are using a custom database, and previously, we were relying on a Salesforce ID and using that ID for the user_id field. However, we now want to use our own unique ID from an auto-incremented field instead. Is there a way that we can migrate the user_id value for these users to new values when these users log in?

Solution

While you cannot change the user_id value of an existing custom database user, you can delete their profiles in Auth0, change the way the custom database script assigns the user_id value, and the next time they log in, a new account will be created the new user_id.

These deleted users would not have valid sessions with Auth0. However, it would be up to your application’s session logic to determine if they’re still considered logged in from the perspective of your application.

Depending on how you’re tracking user sessions, you will want to remove their sessions and have them redirect to your Auth0 login page to log in again in order and create a new authenticated session.