# User error when changing the password

**URL:** <https://community.auth0.com/t/user-error-when-changing-the-password/38707>\
**Category:** Get Help\
**Tags:** auth0\
**Created:** [March 2, 2020, 3:23am UTC](https://community.auth0.com/t/user-error-when-changing-the-password/38707 "2020-03-02T03:23:15Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jorge](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jorge/32/19135_2.png) [@jorge](https://community.auth0.com/u/jorge)\
**Post date:** [March 2, 2020, 3:23am UTC](https://community.auth0.com/t/user-error-when-changing-the-password/38707/1 "2020-03-02T03:23:15Z")

</div>

Good night, I’m using a custom database and I configure the script to change the password, I try it and it works perfect, but when I send the mail to the user to change the password, I see that when I do the submit, it changes the password in the database on mongo, but in the browser tells you that there was an error

 ![Captura](https://global.discourse-cdn.com/auth0/original/3X/7/0/70c333d8179bbd7c0facb8dbefa701d313ad2340.png)

---

<div class="post-metadata">

**Author:** ![rashid779939](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rashid779939/32/27027_2.png) [@rashid779939](https://community.auth0.com/u/rashid779939)\
**Post date:** [March 2, 2020, 5:22am UTC](https://community.auth0.com/t/user-error-when-changing-the-password/38707/2 "2020-03-02T05:22:41Z")

</div>

Hi @jorge,

Can you post your script here for verifications.

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [March 2, 2020, 8:02am UTC](https://community.auth0.com/t/user-error-when-changing-the-password/38707/3 "2020-03-02T08:02:52Z")

</div>

Yes that would be helpful for us!

---

<div class="post-metadata">

**Author:** ![jorge](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jorge/32/19135_2.png) [@jorge](https://community.auth0.com/u/jorge)\
**Post date:** [March 2, 2020, 2:33pm UTC](https://community.auth0.com/t/user-error-when-changing-the-password/38707/4 "2020-03-02T14:33:39Z")

</div>

```
function changePassword(email, newPassword, callback) {
  const bcrypt = require('bcrypt');
  const MongoClient = require('mongodb@3.1.4').MongoClient;
  const dbUser = configuration.dbUser;
  const dbPwd = configuration.dbPwd;
  const dbHost = configuration.dbHost;
  const dbName = configuration.dbName;
  const usersCollection = configuration.usersCollection;
  const uri = `mongodb+srv://${dbUser}:${dbPwd}@${dbHost}/test?retryWrites=true`;
  const client = new MongoClient(uri, { useNewUrlParser: true });

  client.connect(function (err) {
    if (err) return callback(err);

    const db = client.db(dbName);
    const users = db.collection(usersCollection);

    bcrypt.hash(newPassword, 10, function (err, hash) {
      if (err) {
        client.close();
        return callback(err);
      }

      users.update({ email: email }, { $set: { password: hash } }, function (err, count) {
        client.close();
        if (err) return callback(err);
        callback(null, count > 0);
      });
    });
  });
}

```

---

<div class="post-metadata">

**Author:** ![rashid779939](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rashid779939/32/27027_2.png) [@rashid779939](https://community.auth0.com/u/rashid779939)\
**Post date:** [March 3, 2020, 6:39am UTC](https://community.auth0.com/t/user-error-when-changing-the-password/38707/5 "2020-03-03T06:39:10Z")

</div>

Please confirm, this javascript function you calling in password Reset window? If yes then please post your all password reset window code. We need to complete the flow which i believe is missing somehow.

---

<div class="post-metadata">

**Author:** ![chris.shino](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/chris.shino/32/12821_2.png) [@chris.shino](https://community.auth0.com/u/chris.shino)\
**Post date:** [March 11, 2021, 3:11am UTC](https://community.auth0.com/t/user-error-when-changing-the-password/38707/6 "2021-03-11T03:11:10Z")

</div>

Im having the same issue here, its giving me an error of “Something went wrong, please try again later” but it actually is changing the password in the db (im using mongo)
