Auth0 Home Blog Docs

Custom property added that to be unique for all users

custom-database
users
custom-login
custom-property
unique-property

#1

Hi,
here I have mobile as a custom property,

"user_metadata": {
    "mobile": "8373886873",
    "phone_verified": true
  },

and how can I make it unique among all the users mobile property?
can I make this mobile number as a default login username instead of email?


#2

You will need to make a Management API call to ensure that user_metadata.mobile is unique. This can be done from your backend with the following Lucene syntax query, which will return any users that have the same phone number in user_metadata.mobile:

q=user_metadata.mobile:"MOBILE_NUMBER"

If you’d like to use the mobile phone number as the login username, you can use a database connection with Requires username enabled:
https://auth0.com/docs/connections/database/require-username


#3