# Using argon2 custom database

**URL:** <https://community.auth0.com/t/using-argon2-custom-database/123841>\
**Category:** Get Help\
**Tags:** passwordless-email-connection, connections\
**Created:** [December 29, 2023, 9:22am UTC](https://community.auth0.com/t/using-argon2-custom-database/123841 "2023-12-29T09:22:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lug0x](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/lug0x/32/53557_2.png) [@Lug0x](https://community.auth0.com/u/Lug0x)\
**Post date:** [December 29, 2023, 9:22am UTC](https://community.auth0.com/t/using-argon2-custom-database/123841/1 "2023-12-29T09:22:55Z")

</div>

Good morning,

I have the same problem as the person who opened the following topic : [Using argon2 in custom database - Auth0 Community](https://community.auth0.com/t/using-argon2-in-custom-database/85700)

Would anyone have the solution please?

Here is the error and my code:

> Code generated an uncaught exception: TypeError: object null is not iterable (cannot read property Symbol(Symbol.iterator))

```auto
function login(email, password, callback) {
  const MongoClient = require('mongodb').MongoClient;
  const argon2 = require('argon2');
  const client = new MongoClient('mongodb+srv://XXXXX.mongodb.net/?retryWrites=true&w=majority');

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

    const db = client.db('test');
    const users = db.collection('users');

    users.findOne({ email: email }, function (err, user) {
      if (err || !user) {
        client.close();
        return callback(err || new WrongUsernameOrPasswordError(email));
      }
      console.log(argon2);
      argon2.verify(user.password, password)
        .then(() => {
            console.log('Password ok.');
        })
        .catch((error) => {
            console.log('Password NOK.');
        });

			/*if(password === user.password){
      	return callback(null, {
            user_id: user._id.toString(),
            nickname: user.nickname,
            email: user.email
          });
      }*/
      
    });
  });
}

```

---

<div class="post-metadata">

**Author:** ![dawid.matuszczyk](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dawid.matuszczyk/32/74550_2.png) [@dawid.matuszczyk](https://community.auth0.com/u/dawid.matuszczyk)\
**Post date:** [December 30, 2023, 2:30am UTC](https://community.auth0.com/t/using-argon2-custom-database/123841/2 "2023-12-30T02:30:10Z")

</div>

Hi @Lug0x

Welcome to the Auth0 Community!

I’ve checked the tenant of the mentioned post and the user changed the usage of argon2 to bcrypt. This seems as a reasonable change according to my research as bcrypt is better suited for web operations.

I hope this will help you and feel free to ask more questions  
Thanks  
Dawid

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [January 13, 2024, 2:30am UTC](https://community.auth0.com/t/using-argon2-custom-database/123841/3 "2024-01-13T02:30:28Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
