Identify Users

There are two recommended options to uniquely identify your users:

  1. By the user_id property. This is guaranteed to be unique (within a tenant) per user (such as {identity provider id}|{unique id in the provider} or facebook|1234567890). A user may have the same user_id property across multiple Auth0 tenants, but consistency is not guaranteed.

  2. By a natural key, like the email property. In this case, it is recommended that you enable email verification and only use this option with providers that require that users verify their emails.

For regular and custom database connections, avoid creating duplicate user_ids within a tenant for different database connections. If you expect possible collisions between IDs from different connections, you should use a prefix identifying the connection.

The following code sample shows a custom database connection identified with the prefix, MyConnection1|:

function login (email, password, callback) {
  var user = getUserFromDB(email);
  var profile = {
    user_id: 'MyConnection1|' + user.id,
    email: user.email,
    [...]
  };
  callback(null, profile);
}

Was this helpful?

/