Reset password send to secondary email

I have an application, and users are created by API calls. The user information contains username, email, password etc. But is there any option to add the different user with same email id?

For example,
User 1 - Username- abc1, email - abc@gmail.com,password - … etc.
User 2 - Username- abc2, email - abc@gmail.com,password - … etc.

And also I want to send reset password email to abc@gmail.com. How can I do it?

You cannot have two users with the same email address in the same database for the exact reason you mention: Auth0 would have no way of knowing what user the password reset would be for.

Yes, right. But using User name instead email for identify the user. Is it possible ? And reset password link send to email.

No, Auth0 will still use the email as the unique ID for the user, even when also using usernames. :confused:

:pensive: Ok. Then is there any option to send reset password link another email(like secondary email). Not to login email.

Example,
User 1 - Username- abc1, email - abc@gmail.com,secondary_email- xyz@gmail.com.

Login with email -abc@gmail.com
Reset password email sends to xyz@gmail.com.

Is it possible ?

Yes, but this would require some coding off your own.

The Management API allows you to request a Password Reset ticket. This is not the same as sending the reset email. The ticket is just the URL users need to visit to reset their password. So, here’s what you could do:

  1. Have a page where users enter their usernames
  2. Query the Management API for that user, get their secondary email
  3. Request a Password Reset ticket for that user ID
  4. Send a custom email to the secondary email

Sending that email doesn’t have to be hard, either. For our Auth0 deployment, we use SendGrid. They also provide a way to call their API and send an email with a predefined template (so you only have to send the email and ticket URL to the API). I’m sure other email providers allow you to do something similar.

:grinning: Thank you. One more help, how can create a new field (secondary email) in database?

You can use user_metadata or app_metadata, depending on if you want the user to be able to easily edit the field. Those two fields are regular JSON objects, so you can store anything you want in there.

1 Like