How to force a user to reset password

Hello,
I wanted to ask if somebody has any suggestions or preferably, links, to examples of implementation of the reset password for a user. I am having a hard time implementing what the Change password documentation says, without explicit/specific examples.

Any help would be greatly appreciated.

Regards.

Welcome to Auth0 community,

I am guessing you have already looked at this document. There are multiple ways to reset a user’s password.

Please describe your use case a bit more so I can understand which solution best matches your need.

Hello, Thanks for the reply.
Yes, I already read that document and I see some code there for the backend and already try it without much luck.
I am using react and node js for my app. I have a button in my admin dashboard for every user already registered on my site/DB.
When I click that button, I want to force the user to change the password by sending an email notification.
But like I said I already tried the code on the page that you mentioned, I wanted to know if there are more explicit, step-by-step examples somewhere that might help a bit more…

Regards.

Thanks, I understand the use case better now.
So you want to trigger an interactive password reset flow using your NodeJS api.

I think using the Authentication API might be the easiest in this case.

There is already a code snippet provided on the page.

var axios = require("axios").default;

var options = {
  method: 'POST',
  url: 'https://YOUR_DOMAIN/dbconnections/change_password',
  headers: {'content-type': 'application/json'},
  data: {
    client_id: 'YOUR_CLIENT_ID',
    email: '',
    connection: 'Username-Password-Authentication'
  }
};

axios.request(options).then(function (response) {
  console.log(response.data);
}).catch(function (error) {
  console.error(error);
});

If you login to your auth0 account and visit this page it will populate CLIENT_ID and DOMAIN values from your account automatically.

You need an api that can make a http call like the one above to Auth0 Authentication API

You also need to pass the email address of the user you want to reset the password for from your UI to your NodeJS api.
Then you can use this email when you send the reset password request to Auth0 Authentication api.

Calling this api will send the user a reset password email and they can follow instructions on how to reset their password.

Also note this flow is not for social logins like Google, Facebook since the passwords are not kept with Auth0 and needs to be reset with provider.

1 Like

Thanks again, but like I said I’m struggling to understand how to implement that code. I wanted to know if you know any good examples step by step (maybe videos from somebody else?).
Regards.

Hi, I was trying to run the snippet on the page, with the curl command I got

We’ve just sent you an email to reset your password.’

But I have not received the reset email despite me trying multiple times. In the doc there is this line that confuses me

Go to Auth0 Dashboard > Applications > Applications, and add the URL to the Allowed Origins (CORS) list.

what is the URL in this case? Can you add a screenshot of where exactly to paste this URL?
Thanks