Best Practices for Internal User Entity with Auth0

Hey Max!

If the user-related data is not sensitive, you can utilize app_metadata inside your user’s profile (see here). This can eliminate the need for another database. But if the data is sensitive, here is some information regarding your questions.

  1. Using sub as the external ID is a good approach, as the sub/user_id is guaranteed to be unique, as mentioned here in the Auth0 docs and from another community post.
  2. If I understand your question correctly, do you want the user who has logged in/signed up also to have an entry inside your database? If so, you can utilize Auth0 Actions to accomplish this:
    • Login / Post Login
      • This action will run after a user authenticates into your application.
      • You can utilize this in the following manner:
        1. The event parameter is used to acquire the user’s sub.
        2. Use it to query your database
        3. If there are no results, then proceed to create this user entity in your database

Let me know if this helps!

1 Like